Skip to content

Commit 24f3a54

Browse files
committed
npm ci should never save package.json or lockfile
Via: https://github.com/targos/npm7-cra#issue-1-npm-ci-changes-packagejson
1 parent ecd42ce commit 24f3a54

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/ci.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ const ci = async () => {
3333
}),
3434
rimraf(`${where}/node_modules/`)
3535
])
36-
await arb.reify()
36+
// npm ci should never modify the lockfile or package.json
37+
await arb.reify({ save: false })
3738
reifyOutput(arb)
3839
}
3940

test/lib/ci.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ test('should remove existing node_modules before installing', (t) => {
100100
},
101101
'@npmcli/arborist': function () {
102102
this.loadVirtual = () => Promise.resolve(true)
103-
this.reify = async () => {
103+
this.reify = async (options) => {
104+
t.equal(options.save, false, 'npm ci should never save')
104105
// check if node_modules was removed before reifying
105106
const contents = await readdir(testDir)
106107
t.equals(contents.indexOf('node_modules'), -1, 'node_modules does not exist')

0 commit comments

Comments
 (0)