diff options
author | isaacs <i@izs.me> | 2014-09-03 01:11:58 +0400 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2014-09-03 02:19:35 +0400 |
commit | d2d4d7cd3c32f91a87ffa11fe464d524029011c3 (patch) | |
tree | bd9789eacecca9c6aa4529b63dc6df32b1bf7dd0 /lib | |
parent | e913091bd5aa3fb302ee0417db478bd75ae084ed (diff) |
tag: Do not allow tagging with a SemVer range as the tag name
Fix #6082
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tag.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/tag.js b/lib/tag.js index 0d32712cb..47e9a8c0a 100644 --- a/lib/tag.js +++ b/lib/tag.js @@ -9,13 +9,23 @@ var npm = require("./npm.js") , registry = npm.registry , mapToRegistry = require("./utils/map-to-registry.js") , npa = require("npm-package-arg") + , semver = require("semver") function tag (args, cb) { var thing = npa(args.shift() || "") , project = thing.name , version = thing.rawSpec , t = args.shift() || npm.config.get("tag") + + t = t.trim() + if (!project || !version || !t) return cb("Usage:\n"+tag.usage) + + if (semver.validRange(t)) { + var er = new Error("Tag name must not be a valid SemVer range: " + t) + return cb(er) + } + mapToRegistry(project, npm.config, function (er, uri) { if (er) return cb(er) |