No more npm publish -f

Re: https://github.com/npm/npmjs.org/issues/148
This commit is contained in:
isaacs
2014-02-12 17:19:02 -08:00
parent 663f0875a7
commit a52ec5636f
3 changed files with 19 additions and 11 deletions

View File

@@ -106,14 +106,17 @@ function putFirst (data, tardata, stat, username, email, cb) {
function putNext(newVersion, root, current, cb) {
// already have the tardata on the root object
// just merge in existing stuff
// if the version already exists, and not a --force, then raise error
var force = this.conf.get('force')
var curVers = Object.keys(current.versions || {}).map(function (v) {
return semver.clean(v, true)
})
}).concat(Object.keys(current.time || {}).map(function(v) {
if (semver.valid(v, true))
return semver.clean(v, true)
}).filter(function(v) {
return v
}))
if (!force && curVers.indexOf(newVersion) !== -1) {
return cb(conflictError(root.name))
if (curVers.indexOf(newVersion) !== -1) {
return cb(conflictError(root.name, newVersion))
}
current.versions[newVersion] = root.versions[newVersion]
@@ -143,9 +146,10 @@ function putNext(newVersion, root, current, cb) {
this.request("PUT", root.name, current, cb)
}
function conflictError (pkgid) {
var e = new Error("cannot modify existing version")
function conflictError (pkgid, version) {
var e = new Error("cannot modify pre-existing version")
e.code = "EPUBLISHCONFLICT"
e.pkgid = pkgid
e.version = version
return e
}

View File

@@ -6,7 +6,7 @@
},
"name": "npm-registry-client",
"description": "Client for the npm registry",
"version": "0.3.6",
"version": "0.4.0",
"repository": {
"url": "git://github.com/isaacs/npm-registry-client"
},
@@ -38,6 +38,10 @@
"url": "https://github.com/isaacs/npm-registry-client/issues"
},
"homepage": "https://github.com/isaacs/npm-registry-client",
"_id": "npm-registry-client@0.3.6",
"_from": "npm-registry-client@latest"
"_id": "npm-registry-client@0.4.0",
"dist": {
"shasum": "30d0c178b7f2e54183a6a3fc9fe4071eb10290bf"
},
"_from": "npm-registry-client@0.4.0",
"_resolved": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-0.4.0.tgz"
}

View File

@@ -57,7 +57,7 @@
"chownr": "0",
"npmlog": "0.0.6",
"ansi": "~0.2.1",
"npm-registry-client": "~0.3.6",
"npm-registry-client": "~0.4.0",
"read-package-json": "~1.1.7",
"read-installed": "~0.2.2",
"glob": "~3.2.6",