diff --git a/lib/fetcher.js b/lib/fetcher.js index 01058acb..5142bb28 100644 --- a/lib/fetcher.js +++ b/lib/fetcher.js @@ -91,18 +91,11 @@ class FetcherBase { // command to run 'prepare' scripts on directories and git dirs // To use pacote with yarn, for example, set npmBin to 'yarn' - // and npmInstallCmd to ['add'], and npmCliConfig with yarn's equivalents. + // and npmCliConfig with yarn's equivalents. this.npmBin = opts.npmBin || 'npm' // command to install deps for preparing - this.npmInstallCmd = opts.npmInstallCmd || [ - 'install', - '--only=dev', - '--prod', - '--ignore-prepublish', - '--no-progress', - '--no-save', - ] + this.npmInstallCmd = opts.npmInstallCmd || [ 'install' ] // XXX fill more of this in based on what we know from this.opts // we explicitly DO NOT fill in --tag, though, since we are often @@ -113,7 +106,10 @@ class FetcherBase { `--prefer-offline=${!!this.preferOffline}`, `--prefer-online=${!!this.preferOnline}`, `--offline=${!!this.offline}`, - `--before=${this.before ? this.before.toISOString() : ''}`, + ...(this.before ? [`--before=${this.before.toISOString()}`] : []), + '--no-progress', + '--no-save', + '--no-audit', ] } diff --git a/tap-snapshots/test-fetcher.js-TAP.test.js b/tap-snapshots/test-fetcher.js-TAP.test.js index d84a85f2..0449898b 100644 --- a/tap-snapshots/test-fetcher.js-TAP.test.js +++ b/tap-snapshots/test-fetcher.js-TAP.test.js @@ -12,3 +12,55 @@ Object { "resolved": "{CWD}/test/fixtures/bin-object.tgz", } ` + +exports[`test/fetcher.js TAP snapshot the npmInstallCmd and npmInstallConfig > customized npmInstallCmd 1`] = ` +Array [ + "install", + "blerg", +] +` + +exports[`test/fetcher.js TAP snapshot the npmInstallCmd and npmInstallConfig > default install cmd 1`] = ` +Array [ + "install", +] +` + +exports[`test/fetcher.js TAP snapshot the npmInstallCmd and npmInstallConfig > default install cmd with before 1`] = ` +Array [ + "install", +] +` + +exports[`test/fetcher.js TAP snapshot the npmInstallCmd and npmInstallConfig > default install config 1`] = ` +Array [ + "--cache={CACHE}", + "--prefer-offline=false", + "--prefer-online=false", + "--offline=false", + "--no-progress", + "--no-save", + "--no-audit", +] +` + +exports[`test/fetcher.js TAP snapshot the npmInstallCmd and npmInstallConfig > default install config with before 1`] = ` +Array [ + "--cache={CACHE}", + "--prefer-offline=false", + "--prefer-online=false", + "--offline=false", + "--before=1979-07-01T19:10:00.000Z", + "--no-progress", + "--no-save", + "--no-audit", +] +` + +exports[`test/fetcher.js TAP snapshot the npmInstallCmd and npmInstallConfig > yarn style cli config stuff 1`] = ` +Array [ + "--some", + "--yarn", + "--stuff", +] +` diff --git a/tap-snapshots/test-fetcher.js-fake-sudo-TAP.test.js b/tap-snapshots/test-fetcher.js-fake-sudo-TAP.test.js index 958cae76..9392f178 100644 --- a/tap-snapshots/test-fetcher.js-fake-sudo-TAP.test.js +++ b/tap-snapshots/test-fetcher.js-fake-sudo-TAP.test.js @@ -12,3 +12,55 @@ Object { "resolved": "{CWD}/test/fixtures/bin-object.tgz", } ` + +exports[`test/fetcher.js fake-sudo TAP snapshot the npmInstallCmd and npmInstallConfig > customized npmInstallCmd 1`] = ` +Array [ + "install", + "blerg", +] +` + +exports[`test/fetcher.js fake-sudo TAP snapshot the npmInstallCmd and npmInstallConfig > default install cmd 1`] = ` +Array [ + "install", +] +` + +exports[`test/fetcher.js fake-sudo TAP snapshot the npmInstallCmd and npmInstallConfig > default install cmd with before 1`] = ` +Array [ + "install", +] +` + +exports[`test/fetcher.js fake-sudo TAP snapshot the npmInstallCmd and npmInstallConfig > default install config 1`] = ` +Array [ + "--cache={CACHE}", + "--prefer-offline=false", + "--prefer-online=false", + "--offline=false", + "--no-progress", + "--no-save", + "--no-audit", +] +` + +exports[`test/fetcher.js fake-sudo TAP snapshot the npmInstallCmd and npmInstallConfig > default install config with before 1`] = ` +Array [ + "--cache={CACHE}", + "--prefer-offline=false", + "--prefer-online=false", + "--offline=false", + "--before=1979-07-01T19:10:00.000Z", + "--no-progress", + "--no-save", + "--no-audit", +] +` + +exports[`test/fetcher.js fake-sudo TAP snapshot the npmInstallCmd and npmInstallConfig > yarn style cli config stuff 1`] = ` +Array [ + "--some", + "--yarn", + "--stuff", +] +` diff --git a/test/fetcher.js b/test/fetcher.js index 564e3807..7cd32bf7 100644 --- a/test/fetcher.js +++ b/test/fetcher.js @@ -60,6 +60,29 @@ t.test('do not mutate opts object passed in', t => { t.end() }) +t.test('snapshot the npmInstallCmd and npmInstallConfig', async t => { + t.formatSnapshot = o => !Array.isArray(o) ? ou + : o.map(s => s.replace(/^--cache=.*/, '--cache={CACHE}')) + const def = new FileFetcher(abbrevspec, {}) + t.equal(def.npmBin, 'npm', 'use default npm bin') + t.matchSnapshot(def.npmInstallCmd, 'default install cmd') + t.matchSnapshot(def.npmCliConfig, 'default install config') + const bef = new FileFetcher(abbrevspec, { + before: new Date('1979-07-01T19:10:00.000Z'), + }) + t.equal(bef.npmBin, 'npm', 'use default npm bin') + t.matchSnapshot(bef.npmInstallCmd, 'default install cmd with before') + t.matchSnapshot(bef.npmCliConfig, 'default install config with before') + const yarn = new FileFetcher(abbrevspec, { + npmBin: 'yarn', + npmInstallCmd: ['install', 'blerg'], + npmCliConfig: ['--some', '--yarn', '--stuff'], + }) + t.equal(yarn.npmBin, 'yarn', 'use default yarn bin') + t.matchSnapshot(yarn.npmInstallCmd, 'customized npmInstallCmd') + t.matchSnapshot(yarn.npmCliConfig, 'yarn style cli config stuff') +}) + t.test('tarball data', t => new FileFetcher(abbrevspec, { cache }).tarball() .then(data => {