Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class FetcherBase {
// a dist-tag, but certainly wants to keep defaulting to latest.
this.npmCliConfig = opts.npmCliConfig || [
`--cache=${dirname(this.cache)}`,
`--prefer-offline=${!!this.preferOffline}`,
`--prefer-online=${!!this.preferOnline}`,
...(this.preferOffline ? ['--prefer-offline=true'] : []),
...(this.preferOnline ? ['--prefer-online=true'] : []),
`--offline=${!!this.offline}`,
...(this.before ? [`--before=${this.before.toISOString()}`] : []),
'--no-progress',
Expand Down
4 changes: 0 additions & 4 deletions tap-snapshots/test/fetcher.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ Array [
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",
Expand All @@ -55,8 +53,6 @@ Array [
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",
Expand Down
8 changes: 8 additions & 0 deletions test/fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ t.test('snapshot the npmInstallCmd and npmInstallConfig', async t => {
'do not have a _cacache folder on cache config passed to npm cli')
t.equal(basename(def.cache), '_cacache',
'have a _cacache folder on default pacote config itself')
t.not(def.npmCliConfig.includes('--prefer-offline=false'), 'does not pass disabled prefer-offline')
t.not(def.npmCliConfig.includes('--prefer-online=false'), 'does not pass disabled prefer-online')
const preferOffline = new FileFetcher(abbrevspec, { preferOffline: true })
t.ok(preferOffline.npmCliConfig.includes('--prefer-offline=true'), 'passes prefer-offline when enabled')
t.not(preferOffline.npmCliConfig.includes('--prefer-online=true'), 'does not pass prefer-online with prefer-offline')
const preferOnline = new FileFetcher(abbrevspec, { preferOnline: true })
t.ok(preferOnline.npmCliConfig.includes('--prefer-online=true'), 'passes prefer-online when enabled')
t.not(preferOnline.npmCliConfig.includes('--prefer-offline=true'), 'does not pass prefer-offline with prefer-online')
const bef = new FileFetcher(abbrevspec, {
before: new Date('1979-07-01T19:10:00.000Z'),
})
Expand Down