-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 [email protected]` Relates to: #4240
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = [ | ||
'[email protected]', | ||
'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 }), | ||
|