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

unpublish.js « lib - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: aa7b025a726b7a7e45d1400810f00dfceff0f057 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

module.exports = unpublish

var registry = require("./utils/registry")
  , log = require("./utils/log")
  , npm = require("../npm")

unpublish.usage = "npm unpublish <project>[@<version>]"

unpublish.completion = function (args, index, cb) {
  var remotePkgs = require("./utils/completion/remote-packages")
  remotePkgs(args, index, true, false, false, cb)
}

function unpublish (args, cb) {
  var thing = args.shift().split("@")
    , project = thing.shift()
    , version = thing.join("@")
  if (!project) return cb("Usage:\n"+unpublish.usage)
  // remove from the cache first
  npm.commands.cache(["clean", project, version], function (er) {
    if (er) return log.er(cb, "Failed to clean cache")(er)
    registry.unpublish(project, version, cb)
  })
}