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
diff options
context:
space:
mode:
authorRuy Adorno <ruyadorno@hotmail.com>2022-01-26 23:44:18 +0300
committerGitHub <noreply@github.com>2022-01-26 23:44:18 +0300
commitfbe48a84047e0c5de31bdaa84707f0f8fdcef71d (patch)
tree271f116ce36a7c3bfc9b49cb4161ab535d031158 /workspaces/arborist/test
parent1f853f8bf7cecd1222703dde676a4b664526141d (diff)
feat(arborist): add named updates validation (#4307)
* feat(arborist): add named updates validation Arborist update does not support anything other than dependency names, that is confusing to some users that are used to provide semver ranges when using `npm install` and other commands. This changeset adds validation to the values provided as arguments in `npm update` and will throw a `EUPDATEARGS` error in case the user tries to use semver ranges, e.g: `npm update abbrev@1.0.0` Relates to: https://github.com/npm/cli/issues/4240
Diffstat (limited to 'workspaces/arborist/test')
-rw-r--r--workspaces/arborist/test/arborist/build-ideal-tree.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/workspaces/arborist/test/arborist/build-ideal-tree.js b/workspaces/arborist/test/arborist/build-ideal-tree.js
index d8bfe8200..be3a40042 100644
--- a/workspaces/arborist/test/arborist/build-ideal-tree.js
+++ b/workspaces/arborist/test/arborist/build-ideal-tree.js
@@ -2098,6 +2098,22 @@ t.test('update global', async t => {
t.matchSnapshot(await printIdeal(path, { global: true, update: ['wrappy'] }),
'updating sub-dep has no effect')
+
+ const invalidArgs = [
+ 'once@1.4.0',
+ 'once@next',
+ 'once@^1.0.0',
+ 'once@>=2.0.0',
+ 'once@2',
+ ]
+ for (const updateName of invalidArgs) {
+ t.rejects(
+ printIdeal(path, { global: true, update: [updateName] }),
+ { code: 'EUPDATEARGS' },
+ 'should throw an error when using semver ranges'
+ )
+ }
+
t.matchSnapshot(await printIdeal(path, { global: true, update: ['once'] }),
'update a single dep')
t.matchSnapshot(await printIdeal(path, { global: true, update: true }),