]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/init-interrupt.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / init-interrupt.js
1 // if "npm init" is interrupted with ^C, don't report
2 // "init written successfully"
3 var test = require("tap").test
4 var path = require("path")
5 var osenv = require("osenv")
6 var rimraf = require("rimraf")
7 var npmlog = require("npmlog")
8 var requireInject = require("require-inject")
9
10 var npm = require("../../lib/npm.js")
11
12 var PKG_DIR = path.resolve(__dirname, "init-interrupt")
13
14 test("setup", function (t) {
15   cleanup()
16
17   t.end()
18 })
19
20 test("issue #6684 remove confusing message", function (t) {
21
22   var initJsonMock = function (dir, input, config, cb) {
23     process.nextTick(function () {
24       cb({message : "canceled"})
25     })
26   }
27   initJsonMock.yes = function () { return true }
28
29   npm.load({loglevel : "silent"}, function () {
30     var log = ""
31     var init = requireInject("../../lib/init", {
32       "init-package-json": initJsonMock
33     })
34
35     // capture log messages
36     npmlog.on("log", function (chunk) { log += chunk.message + "\n" } )
37
38     init([], function (err, code) {
39       t.ifError(err, "init ran successfully")
40       t.notOk(code, "exited without issue")
41       t.notSimilar(log, /written successfully/, "no success message written")
42       t.similar(log, /canceled/, "alerted that init was canceled")
43
44       t.end()
45     })
46   })
47 })
48
49 test("cleanup", function (t) {
50   cleanup()
51
52   t.end()
53 })
54
55 function cleanup () {
56   process.chdir(osenv.tmpdir())
57   rimraf.sync(PKG_DIR)
58 }