Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/commands/dist-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ class DistTag extends BaseCommand {

log.verbose('dist-tag add', defaultTag, 'to', spec.name + '@' + version)

// make sure new spec with tag is valid, this will throw if invalid
npa(`${spec.name}@${defaultTag}`)

if (!spec.name || !version || !defaultTag) {
throw this.usageError('must provide a spec with a name and version, and a tag to add')
}
Expand Down
9 changes: 9 additions & 0 deletions test/lib/commands/dist-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,15 @@ t.test('add missing pkg name', async t => {
)
})

t.test('add invalid tag', async t => {
const { distTag } = await mockDist(t)
await t.rejects(
distTag.exec(['add', '@tag']),
{ code: 'EINVALIDTAGNAME' },
'should exit with invalid tag name error'
)
})

t.test('set existing version', async t => {
const { distTag, logs } = await mockDist(t)
await distTag.exec(['set', '@scoped/[email protected]', 'b'])
Expand Down