Commit bbbd300

Anton Medvedev <anton@medv.io>
2021-05-11 12:30:23
Use which package
1 parent 91d344c
Changed files (2)
index.mjs
@@ -13,9 +13,10 @@
 // limitations under the License.
 
 import {existsSync} from 'fs'
-import {exec, execSync} from 'child_process'
+import {exec} from 'child_process'
 import {createInterface} from 'readline'
 import {default as nodeFetch} from 'node-fetch'
+import which from 'which'
 import chalk from 'chalk'
 import shq from 'shq'
 
@@ -72,7 +73,7 @@ $.verbose = true
 // Try `command`, should cover all Bourne-like shells.
 // Try `which`, should cover most other cases.
 // Try `type` command, if the rest fails.
-$.shell = `${execSync('command -v bash || which bash || type -p bash')}`.trim()
+$.shell = which.sync('bash', {nothrow: true})
 $.prefix = 'set -euo pipefail;'
 $.quote = shq
 $.cwd = undefined
package.json
@@ -17,7 +17,8 @@
     "chalk": "^4.1.1",
     "node-fetch": "^2.6.1",
     "shq": "^1.0.2",
-    "uuid": "^8.3.2"
+    "uuid": "^8.3.2",
+    "which": "^2.0.2"
   },
   "publishConfig": {
     "registry": "https://wombat-dressing-room.appspot.com"