Skip to content

Commit 59d53b3

Browse files
authored
fix: throws an err when alias is without name (#184)
throws error when alias spec is without name. e.g. ( foo@npm: ) Fixes: npm/cli#7590
1 parent 74d06ae commit 59d53b3

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/npa.js

+4
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,10 @@ function fromAlias (res, where) {
380380
throw new Error('aliases only work for registry deps')
381381
}
382382

383+
if (!subSpec.name) {
384+
throw new Error('aliases must have a name')
385+
}
386+
383387
res.subSpec = subSpec
384388
res.registry = true
385389
res.type = 'alias'

test/basic.js

+4
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,10 @@ t.test('basic', function (t) {
692692
npa('foo@npm:bar@npm:baz')
693693
}, 'nested aliases not supported')
694694

695+
t.throws(() => {
696+
npa('foo@npm:')
697+
}, 'aliases must have a name')
698+
695699
t.throws(() => {
696700
npa('foo@npm:foo/bar')
697701
}, 'aliases only work for registry deps')

0 commit comments

Comments
 (0)