Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass flatOptions through to Arborist.reify in npm ci #2159

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion lib/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const ci = async () => {
rimraf(`${where}/node_modules/*`, { glob: { dot: true, nosort: true, silent: true } }),
])
// npm ci should never modify the lockfile or package.json
await arb.reify({ save: false })
await arb.reify({ ...npm.flatOptions, save: false })
reifyOutput(arb)
}

Expand Down
19 changes: 19 additions & 0 deletions test/lib/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@ test('should use Arborist', (t) => {
})
})

test('should pass flatOptions to Arborist.reify', (t) => {
const ci = requireInject('../../lib/ci.js', {
'../../lib/npm.js': {
prefix: 'foo',
flatOptions: {
production: true
}
},
'@npmcli/arborist': function () {
this.loadVirtual = () => Promise.resolve(true)
this.reify = async (options) => {
t.equal(options.production, true, 'should pass flatOptions to Arborist.reify')
t.end()
}
}
})
ci(null, () => {})
})

test('should throw if package-lock.json or npm-shrinkwrap missing', (t) => {
const testDir = t.testdir({
'index.js': 'some contents',
Expand Down