« get me outta code hell

Windows support! - http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src/command-exists.js
diff options
context:
space:
mode:
authortowerofnix <towerofnix@gmail.com>2017-08-07 21:10:00 -0300
committertowerofnix <towerofnix@gmail.com>2017-08-07 21:12:19 -0300
commit588482d3dad9a3ff023b6a152c490e375eb6746a (patch)
tree5a78d0e2ac765d105718075ad7877e6d744130b4 /src/command-exists.js
parente70c189576a80a162a3183172aac74f288e66ccd (diff)
Windows support!
(Hopefully this didn't break macOS/Linux.)
Diffstat (limited to 'src/command-exists.js')
-rwxr-xr-xsrc/command-exists.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/command-exists.js b/src/command-exists.js
new file mode 100755
index 0000000..9921364
--- /dev/null
+++ b/src/command-exists.js
@@ -0,0 +1,12 @@
+const npmCommandExists = require('command-exists')
+
+module.exports = 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
+  }
+}