Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
fix(npm): escape path to npm, too
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Jul 15, 2017
1 parent b0a708a commit 333d2ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function getEnv (opts) {
const args = ['run', 'env', '--parseable']
return findNodeScript(opts.npm, {isLocal: true}).then(npmPath => {
if (npmPath) {
args.unshift(opts.npm)
args.unshift(child.escapeArg(opts.npm, true))
return process.argv[0]
} else {
return opts.npm
Expand Down Expand Up @@ -194,7 +194,7 @@ function getNpmCache (opts) {
}
return findNodeScript(opts.npm, {isLocal: true}).then(npmPath => {
if (npmPath) {
args.unshift(opts.npm)
args.unshift(child.escapeArg(opts.npm, true))
return process.argv[0]
} else {
return opts.npm
Expand All @@ -220,7 +220,7 @@ function installPackages (specs, prefix, opts) {
const args = buildArgs(specs, prefix, opts)
return findNodeScript(opts.npm, {isLocal: true}).then(npmPath => {
if (npmPath) {
args.unshift(opts.npm)
args.unshift(child.escapeArg(opts.npm, true))
return process.argv[0]
} else {
return opts.npm
Expand Down
6 changes: 3 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ test('execCommand unit', {
process.exitCode = oldCode
})
})
})
})

test('installPackages unit', t => {
const installPkgs = requireInject('../index.js', {
Expand Down Expand Up @@ -160,12 +160,12 @@ test('getNpmCache', t => {
}
})._getNpmCache
return getCache({npm: NPM_PATH}).then(cache => {
t.equal(cache, `${process.argv[0]} ${NPM_PATH} config get cache --parseable`, 'requests cache from npm')
t.equal(cache, `${process.argv[0]} ${NPM_PATH}-escaped-as-path-true config get cache --parseable`, 'requests cache from npm')
return getCache({npm: NPM_PATH, userconfig})
}).then(cache => {
t.equal(
cache,
`${process.argv[0]} ${NPM_PATH} config get cache --parseable --userconfig ${
`${process.argv[0]} ${NPM_PATH}-escaped-as-path-true config get cache --parseable --userconfig ${
userconfig
}-escaped-as-path-true`,
'added userconfig if option present'
Expand Down

0 comments on commit 333d2ff

Please sign in to comment.