Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPelle Wessman <pelle@kodfabrik.se>2021-10-15 13:51:41 +0300
committerLuke Karrys <luke@lukekarrys.com>2021-10-27 19:37:40 +0300
commitcb9f43551f46bf27095cd7bd6c1885a441004cd2 (patch)
tree41ffb54786a257a63874181df1f7522908c07745 /lib
parent62c731545e83f3c7f890d6b4feb6f7544884bd3c (diff)
fix: allow `--lockfile-version` config to be string and coerce to number
As all CLI input is considered to be string, eg. a "npm install --lockfile-version 3" would fail with the error messages: ``` npm WARN invalid config lockfile-version="3" set in command line options npm WARN invalid config Must be one of: null, 1, 2, 3 ``` Until we have a config system that supports setting type and possible values of configs, we have to specify all string and number values for the `lockfile-version`, but we coerce all values to numbers in the flattener. Co-authored-by: @voxpelli Co-authored-by: @isaacs PR-URL: https://github.com/npm/cli/pull/3949 Credit: @lukekarrys Close: #3949 Reviewed-by: @isaacs
Diffstat (limited to 'lib')
-rw-r--r--lib/utils/config/definitions.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/utils/config/definitions.js b/lib/utils/config/definitions.js
index c9806b3c2..a725ee0fa 100644
--- a/lib/utils/config/definitions.js
+++ b/lib/utils/config/definitions.js
@@ -1157,7 +1157,7 @@ define('location', {
define('lockfile-version', {
default: null,
- type: [null, 1, 2, 3],
+ type: [null, 1, 2, 3, '1', '2', '3'],
defaultDescription: `
Version 2 if no lockfile or current lockfile version less than or equal to
2, otherwise maintain current lockfile version
@@ -1179,7 +1179,9 @@ define('lockfile-version', {
on disk than lockfile version 2, but not interoperable with older npm
versions. Ideal if all users are on npm version 7 and higher.
`,
- flatten,
+ flatten: (key, obj, flatOptions) => {
+ flatOptions.lockfileVersion = obj[key] && parseInt(obj[key], 10)
+ },
})
define('loglevel', {