From 8cb75a295ce7b2cb21b34d72807a2ba9626270d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Tue, 27 Jun 2017 14:19:56 -0700 Subject: [PATCH] fix(npm): Use --parseable option to work around output quirks --- index.js | 6 ++++-- test/index.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 22fad5e..f0dba0a 100755 --- a/index.js +++ b/index.js @@ -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 @@ -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)) } diff --git a/test/index.js b/test/index.js index 992ad30..5511d0b 100644 --- a/test/index.js +++ b/test/index.js @@ -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'