Skip to content

Commit

Permalink
fix: pass flatOptions through to Arborist.reify in npm ci
Browse files Browse the repository at this point in the history
Fixes: npm#2017

Credit: @darcyclarke
Close: npm#2159
Reviewed-by: @ruyadorno
  • Loading branch information
darcyclarke authored and isaacs committed Nov 13, 2020
1 parent b47ada7 commit 786e364
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
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

0 comments on commit 786e364

Please sign in to comment.