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")
10 var npm = require("../../lib/npm.js")
12 var PKG_DIR = path.resolve(__dirname, "init-interrupt")
14 test("setup", function (t) {
20 test("issue #6684 remove confusing message", function (t) {
22 var initJsonMock = function (dir, input, config, cb) {
23 process.nextTick(function () {
24 cb({message : "canceled"})
27 initJsonMock.yes = function () { return true }
29 npm.load({loglevel : "silent"}, function () {
31 var init = requireInject("../../lib/init", {
32 "init-package-json": initJsonMock
35 // capture log messages
36 npmlog.on("log", function (chunk) { log += chunk.message + "\n" } )
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")
49 test("cleanup", function (t) {
56 process.chdir(osenv.tmpdir())