diff --git a/lib/exec.js b/lib/exec.js index 7e5f6886a3ed7..959fab66634bd 100644 --- a/lib/exec.js +++ b/lib/exec.js @@ -67,7 +67,6 @@ class Exec extends BaseCommand { // can be named correctly async _exec (_args, { locationMsg, path, runPath }) { const args = [..._args] - const cache = this.npm.config.get('cache') const call = this.npm.config.get('call') const color = this.npm.config.get('color') const { @@ -88,7 +87,6 @@ class Exec extends BaseCommand { ...flatOptions, args, call, - cache, color, localBin, locationMsg, diff --git a/lib/init.js b/lib/init.js index 4dd091601e191..d34f92b882b32 100644 --- a/lib/init.js +++ b/lib/init.js @@ -106,7 +106,6 @@ class Init extends BaseCommand { } const newArgs = [packageName, ...otherArgs] - const cache = this.npm.config.get('cache') const { color } = this.npm.flatOptions const { flatOptions, @@ -128,7 +127,6 @@ class Init extends BaseCommand { await libexec({ ...flatOptions, args: newArgs, - cache, color, localBin, locationMsg, diff --git a/test/lib/exec.js b/test/lib/exec.js index 6924783239b49..c1b2438fce43e 100644 --- a/test/lib/exec.js +++ b/test/lib/exec.js @@ -24,11 +24,12 @@ let PROGRESS_ENABLED = true const LOG_WARN = [] let PROGRESS_IGNORED = false const flatOptions = { + cache: 'cache-dir', legacyPeerDeps: false, package: [], } const config = { - cache: 'cache-dir', + cache: 'bad-cache-dir', // this should never show up passed into libnpmexec yes: true, call: '', package: [], diff --git a/test/lib/init.js b/test/lib/init.js index 268b170cb4839..a05c52dcc64e6 100644 --- a/test/lib/init.js +++ b/test/lib/init.js @@ -12,10 +12,14 @@ const npmLog = { silly: () => null, } const config = { + cache: 'bad-cache-dir', 'init-module': '~/.npm-init.js', yes: true, } const npm = mockNpm({ + flatOptions: { + cache: 'test-config-dir', + }, config, log: npmLog, }) @@ -82,16 +86,17 @@ t.test('classic interactive npm init', t => { }) t.test('npm init ', t => { - t.plan(1) + t.plan(2) npm.localPrefix = t.testdir({}) const Init = t.mock('../../lib/init.js', { - libnpmexec: ({ args }) => { + libnpmexec: ({ args, cache }) => { t.same( args, ['create-react-app'], 'should npx with listed packages' ) + t.same(cache, 'test-config-dir') }, }) const init = new Init(npm)