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: 426e5789b6b37f6bfbfe3f1a85e4989d2018a7fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

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>] ...]"

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)
    })
  })
}