summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/libnpx/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/libnpx/index.js')
-rw-r--r--deps/npm/node_modules/libnpx/index.js30
1 files changed, 21 insertions, 9 deletions
diff --git a/deps/npm/node_modules/libnpx/index.js b/deps/npm/node_modules/libnpx/index.js
index 7c0bd6df85..d42172e500 100644
--- a/deps/npm/node_modules/libnpx/index.js
+++ b/deps/npm/node_modules/libnpx/index.js
@@ -126,9 +126,13 @@ function localBinPath (cwd) {
module.exports._getEnv = getEnv
function getEnv (opts) {
const args = ['run', 'env', '--parseable']
- return which(opts.npm).catch(() => {
- args.unshift(opts.npm)
- return process.argv[0]
+ return findNodeScript(opts.npm, {isLocal: true}).then(npmPath => {
+ if (npmPath) {
+ args.unshift(opts.npm)
+ return process.argv[0]
+ } else {
+ return opts.npm
+ }
}).then(npmPath => {
return child.exec(npmPath, args)
}).then(require('dotenv').parse)
@@ -188,9 +192,13 @@ function getNpmCache (opts) {
if (opts.userconfig) {
args.push('--userconfig', child.escapeArg(opts.userconfig, true))
}
- return which(opts.npm).catch(() => {
- args.unshift(opts.npm)
- return process.argv[0]
+ return findNodeScript(opts.npm, {isLocal: true}).then(npmPath => {
+ if (npmPath) {
+ args.unshift(opts.npm)
+ return process.argv[0]
+ } else {
+ return opts.npm
+ }
}).then(npmPath => {
return child.exec(npmPath, args)
}).then(cache => cache.trim())
@@ -210,9 +218,13 @@ function buildArgs (specs, prefix, opts) {
module.exports._installPackages = installPackages
function installPackages (specs, prefix, opts) {
const args = buildArgs(specs, prefix, opts)
- return which(opts.npm).catch(() => {
- args.unshift(opts.npm)
- return process.argv[0]
+ return findNodeScript(opts.npm, {isLocal: true}).then(npmPath => {
+ if (npmPath) {
+ args.unshift(opts.npm)
+ return process.argv[0]
+ } else {
+ return opts.npm
+ }
}).then(npmPath => {
return child.escapeArg(npmPath, true)
}).then(npmPath => {