diff options
Diffstat (limited to 'deps/npm/node_modules/libnpx/index.js')
-rw-r--r-- | deps/npm/node_modules/libnpx/index.js | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/deps/npm/node_modules/libnpx/index.js b/deps/npm/node_modules/libnpx/index.js index 3033e9cd06..e65cd7207b 100644 --- a/deps/npm/node_modules/libnpx/index.js +++ b/deps/npm/node_modules/libnpx/index.js @@ -86,6 +86,9 @@ function npx (argv) { if (process.platform === 'win32') { bins = bins.filter(b => b !== 'etc' && b !== 'node_modules') } + if (bins.length < 1) { + throw new Error(Y()`command not found: ${argv.command}`) + } const cmd = new RegExp(`^${argv.command}(?:\\.cmd)?$`, 'i') const matching = bins.find(b => b.match(cmd)) return path.resolve(results.bin, bins[matching] || bins[0]) @@ -116,11 +119,7 @@ function npx (argv) { module.exports._localBinPath = localBinPath function localBinPath (cwd) { return require('./get-prefix.js')(cwd).then(prefix => { - const pkgjson = path.join(prefix, 'package.json') - return promisify(fs.stat)(pkgjson).then( - () => path.join(prefix, 'node_modules', '.bin'), - err => { if (err.code !== 'ENOENT') throw err } - ) + return prefix && path.join(prefix, 'node_modules', '.bin') }) } @@ -146,8 +145,8 @@ function ensurePackages (specs, opts) { ).then(cache => { const prefix = path.join(cache, '_npx', process.pid.toString()) const bins = process.platform === 'win32' - ? prefix - : path.join(prefix, 'bin') + ? prefix + : path.join(prefix, 'bin') const rimraf = require('rimraf') process.on('exit', () => rimraf.sync(prefix)) return promisify(rimraf)(bins).then(() => { @@ -224,8 +223,8 @@ function installPackages (specs, prefix, opts) { if (npmPath) { args.unshift( process.platform === 'win32' - ? child.escapeArg(opts.npm) - : opts.npm + ? child.escapeArg(opts.npm) + : opts.npm ) return process.argv[0] } else { @@ -355,7 +354,7 @@ function findNodeScript (existing, opts) { return str.match(cmd) || str.match(mingw) }).then(match => { return match && path.join(path.dirname(existing), match[1]) - }).then(x => console.log(x) || x) + }) } }) } |