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

restart.js « lib - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: eec0cbc3cd3e72173a00016de0a19591dfd12d10 (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
26

module.exports = restart

var lifecycle = require("./utils/lifecycle")
  , stop = lifecycle.cmd("stop")
  , start = lifecycle.cmd("start")
  , restartCmd = lifecycle.cmd("restart", true)
  , log = require("./utils/log")

restart.usage = "npm restart <name>[@<version>] [<name>[@<version>] ...]"

restart.completion = function (args, index, cb) {
  var installedPkgs = require("./utils/completion/installed-packages")
  installedPkgs(args, index, true, true, cb)
}

function restart (args, cb) {
  restartCmd(args, function (er) {
    if (!er) return cb()
    if (er.message !== "Nothing to do") return cb(er)
    stop(args, function (er) {
      if (er) return log.er(cb, "Failed to stop")(er)
      start(args, cb)
    })
  })
}