Skip to content

Commit c0519ed

Browse files
committed
fix(ci): should not use package-lock config
`npm ci` should never be affected by the `package-lock` config. Fixes: #4185
1 parent 457e0ae commit c0519ed

File tree

6 files changed

+11
-1
lines changed

6 files changed

+11
-1
lines changed

docs/content/using-npm/config.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,8 @@ When package package-locks are disabled, automatic pruning of extraneous
11901190
modules will also be disabled. To remove extraneous modules with
11911191
package-locks disabled use `npm prune`.
11921192

1193+
This configuration does not affect `npm ci`.
1194+
11931195
<!-- automatically generated, do not edit manually -->
11941196
<!-- see lib/utils/config/definitions.js -->
11951197

lib/commands/ci.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class CI extends ArboristWorkspaceCmd {
3838
const where = this.npm.prefix
3939
const opts = {
4040
...this.npm.flatOptions,
41+
packageLock: true, // npm ci should never skip lock files
4142
path: where,
4243
log,
4344
save: false, // npm ci should never modify the lockfile or package.json

lib/utils/config/definitions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,8 @@ define('package-lock', {
14171417
When package package-locks are disabled, automatic pruning of extraneous
14181418
modules will also be disabled. To remove extraneous modules with
14191419
package-locks disabled use \`npm prune\`.
1420+
1421+
This configuration does not affect \`npm ci\`.
14201422
`,
14211423
flatten: (key, obj, flatOptions) => {
14221424
flatten(key, obj, flatOptions)

tap-snapshots/test/lib/utils/config/definitions.js.test.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,8 @@ will also prevent _writing_ \`package-lock.json\` if \`save\` is true.
12711271
When package package-locks are disabled, automatic pruning of extraneous
12721272
modules will also be disabled. To remove extraneous modules with
12731273
package-locks disabled use \`npm prune\`.
1274+
1275+
This configuration does not affect \`npm ci\`.
12741276
`
12751277

12761278
exports[`test/lib/utils/config/definitions.js TAP > config description for package-lock-only 1`] = `

tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,8 @@ When package package-locks are disabled, automatic pruning of extraneous
10641064
modules will also be disabled. To remove extraneous modules with
10651065
package-locks disabled use \`npm prune\`.
10661066
1067+
This configuration does not affect \`npm ci\`.
1068+
10671069
<!-- automatically generated, do not edit manually -->
10681070
<!-- see lib/utils/config/definitions.js -->
10691071

test/lib/commands/ci.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ t.test('should throw ECIGLOBAL', async t => {
232232
})
233233

234234
t.test('should remove existing node_modules before installing', async t => {
235-
t.plan(2)
235+
t.plan(3)
236236
const testDir = t.testdir({
237237
node_modules: {
238238
'some-file': 'some contents',
@@ -245,6 +245,7 @@ t.test('should remove existing node_modules before installing', async t => {
245245
'@npmcli/arborist': function () {
246246
this.loadVirtual = () => Promise.resolve(true)
247247
this.reify = async (options) => {
248+
t.equal(options.packageLock, true, 'npm ci should never ignore lock')
248249
t.equal(options.save, false, 'npm ci should never save')
249250
// check if node_modules was removed before reifying
250251
const contents = await readdir(testDir)

0 commit comments

Comments
 (0)