Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/unpublish.js')
-rw-r--r--lib/unpublish.js56
1 files changed, 29 insertions, 27 deletions
diff --git a/lib/unpublish.js b/lib/unpublish.js
index c692730a9..63f87b820 100644
--- a/lib/unpublish.js
+++ b/lib/unpublish.js
@@ -1,15 +1,15 @@
module.exports = unpublish
-var log = require("npmlog")
-var npm = require("./npm.js")
-var readJson = require("read-package-json")
-var path = require("path")
-var mapToRegistry = require("./utils/map-to-registry.js")
-var npa = require("npm-package-arg")
-var getPublishConfig = require("./utils/get-publish-config.js")
+var log = require('npmlog')
+var npm = require('./npm.js')
+var readJson = require('read-package-json')
+var path = require('path')
+var mapToRegistry = require('./utils/map-to-registry.js')
+var npa = require('npm-package-arg')
+var getPublishConfig = require('./utils/get-publish-config.js')
-unpublish.usage = "npm unpublish [<@scope>/]<pkg>[@<version>]"
+unpublish.usage = 'npm unpublish [<@scope>/]<pkg>[@<version>]'
unpublish.completion = function (opts, cb) {
if (opts.conf.argv.remain.length >= 3) return cb()
@@ -18,11 +18,11 @@ unpublish.completion = function (opts, cb) {
var un = encodeURIComponent(username)
if (!un) return cb()
- var byUser = "-/by-user/" + un
+ var byUser = '-/by-user/' + un
mapToRegistry(byUser, npm.config, function (er, uri, auth) {
if (er) return cb(er)
- npm.registry.get(uri, { auth : auth }, function (er, pkgs) {
+ npm.registry.get(uri, { auth: auth }, function (er, pkgs) {
// do a bit of filtering at this point, so that we don't need
// to fetch versions for more than one thing, but also don't
// accidentally a whole project.
@@ -36,12 +36,12 @@ unpublish.completion = function (opts, cb) {
mapToRegistry(pkgs[0], npm.config, function (er, uri, auth) {
if (er) return cb(er)
- npm.registry.get(uri, { auth : auth }, function (er, d) {
+ npm.registry.get(uri, { auth: auth }, function (er, d) {
if (er) return cb(er)
var vers = Object.keys(d.versions)
if (!vers.length) return cb(null, pkgs)
return cb(null, vers.map(function (v) {
- return pkgs[0] + "@" + v
+ return pkgs[0] + '@' + v
}))
})
})
@@ -54,24 +54,26 @@ function unpublish (args, cb) {
if (args.length > 1) return cb(unpublish.usage)
var thing = args.length ? npa(args[0]) : {}
- , project = thing.name
- , version = thing.rawSpec
-
- log.silly("unpublish", "args[0]", args[0])
- log.silly("unpublish", "thing", thing)
- if (!version && !npm.config.get("force")) {
- return cb("Refusing to delete entire project.\n"
- + "Run with --force to do this.\n"
- + unpublish.usage)
+ var project = thing.name
+ var version = thing.rawSpec
+
+ log.silly('unpublish', 'args[0]', args[0])
+ log.silly('unpublish', 'thing', thing)
+ if (!version && !npm.config.get('force')) {
+ return cb(
+ 'Refusing to delete entire project.\n' +
+ 'Run with --force to do this.\n' +
+ unpublish.usage
+ )
}
if (!project || path.resolve(project) === npm.localPrefix) {
// if there's a package.json in the current folder, then
// read the package name and version out of that.
- var cwdJson = path.join(npm.localPrefix, "package.json")
+ var cwdJson = path.join(npm.localPrefix, 'package.json')
return readJson(cwdJson, function (er, data) {
- if (er && er.code !== "ENOENT" && er.code !== "ENOTDIR") return cb(er)
- if (er) return cb("Usage:\n" + unpublish.usage)
+ if (er && er.code !== 'ENOENT' && er.code !== 'ENOTDIR') return cb(er)
+ if (er) return cb('Usage:\n' + unpublish.usage)
log.verbose('unpublish', data)
gotProject(data.name, data.version, data.publishConfig, cb)
})
@@ -87,7 +89,7 @@ function gotProject (project, version, publishConfig, cb_) {
function cb (er) {
if (er) return cb_(er)
- console.log("- " + project + (version ? "@" + version : ""))
+ console.log('- ' + project + (version ? '@' + version : ''))
cb_()
}
@@ -96,9 +98,9 @@ function gotProject (project, version, publishConfig, cb_) {
var registry = mappedConfig.client
// remove from the cache first
- npm.commands.cache(["clean", project, version], function (er) {
+ npm.commands.cache(['clean', project, version], function (er) {
if (er) {
- log.error("unpublish", "Failed to clean cache")
+ log.error('unpublish', 'Failed to clean cache')
return cb(er)
}