diff options
-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' |