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

Commit

Permalink
fix(npm): Use --parseable option to work around output quirks
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Jun 27, 2017
1 parent 612f7ab commit 8cb75a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ function localBinPath (cwd) {

module.exports._getEnv = getEnv
function getEnv (opts) {
return child.exec(opts.npm, ['run', 'env']).then(require('dotenv').parse)
return child.exec(opts.npm, [
'run', 'env', '--parseable'
]).then(require('dotenv').parse)
}

module.exports._ensurePackages = ensurePackages
Expand Down Expand Up @@ -165,7 +167,7 @@ function getExistingPath (command, opts) {
module.exports._getNpmCache = getNpmCache
function getNpmCache (opts) {
return which(opts.npm).then(npmPath => {
const args = ['config', 'get', 'cache']
const args = ['config', 'get', 'cache', '--parseable']
if (opts.userconfig) {
args.push('--userconfig', child.escapeArg(opts.userconfig, true))
}
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ test('getNpmCache', t => {
}
})._getNpmCache
return getCache({npm}).then(cache => {
t.equal(cache, `${npm} config get cache`, 'requests cache from npm')
t.equal(cache, `${npm} config get cache --parseable`, 'requests cache from npm')
return getCache({npm, userconfig})
}).then(cache => {
t.equal(
cache,
`${npm} config get cache --userconfig ${
`${npm} config get cache --parseable --userconfig ${
userconfig
}-escaped-as-path-true`,
'added userconfig if option present'
Expand Down

0 comments on commit 8cb75a2

Please sign in to comment.