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/test
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 /test
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 'test')
-rw-r--r--test/lib/utils/config/definitions.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/lib/utils/config/definitions.js b/test/lib/utils/config/definitions.js
index 622e603bc..15b43715f 100644
--- a/test/lib/utils/config/definitions.js
+++ b/test/lib/utils/config/definitions.js
@@ -892,3 +892,12 @@ t.test('workspaces derived', t => {
t.equal(flat.workspacesEnabled, false)
t.end()
})
+
+t.test('lockfile version', t => {
+ const flat = {}
+ definitions['lockfile-version'].flatten('lockfile-version', {
+ 'lockfile-version': '3',
+ }, flat)
+ t.match(flat.lockfileVersion, 3, 'flattens to a number')
+ t.end()
+})