diff options
author | liam4 <towerofnix@gmail.com> | 2017-07-24 20:39:31 -0300 |
---|---|---|
committer | liam4 <towerofnix@gmail.com> | 2017-07-24 20:39:31 -0300 |
commit | bb1a0d08e408f949d3b94206f8b5883a659f4d0d (patch) | |
tree | 9e9112f72e65246daacbf605d2d7219abed3e95c /src | |
parent | 39e0b6051e49165d56ba0e88484cb18f9f20de66 (diff) |
Make commandExists actually work when a command doesn't exist
Diffstat (limited to 'src')
-rwxr-xr-x | src/play.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/play.js b/src/play.js index a94e2aa..35001be 100755 --- a/src/play.js +++ b/src/play.js @@ -6,7 +6,7 @@ const { promisify } = require('util') const clone = require('clone') const fs = require('fs') const fetch = require('node-fetch') -const commandExists = require('command-exists') +const npmCommandExists = require('command-exists') const pickers = require('./pickers') const loopPlay = require('./loop-play') const processArgv = require('./process-argv') @@ -40,6 +40,17 @@ function clearConsoleLine() { process.stdout.write('\x1b[1K\r') } +async function commandExists(command) { + // When the command-exists module sees that a given command doesn't exist, it + // throws an error instead of returning false, which is not what we want. + + try { + return await npmCommandExists(command) + } catch(err) { + return false + } +} + async function determineDefaultPlayer() { if (await commandExists('mpv')) { return 'mpv' |