1/* eslint-disable standard/no-callback-literal */ 2// if 'npm init' is interrupted with ^C, don't report 3// 'init written successfully' 4var test = require('tap').test 5var npmlog = require('npmlog') 6var requireInject = require('require-inject') 7 8var npm = require('../../lib/npm.js') 9 10require('../common-tap.js') 11 12test('issue #6684 remove confusing message', function (t) { 13 var initJsonMock = function (dir, input, config, cb) { 14 process.nextTick(function () { 15 cb({ message: 'canceled' }) 16 }) 17 } 18 initJsonMock.yes = function () { return true } 19 20 npm.load({ loglevel: 'silent' }, function () { 21 var log = '' 22 var init = requireInject('../../lib/init', { 23 'init-package-json': initJsonMock 24 }) 25 26 // capture log messages 27 npmlog.on('log', function (chunk) { log += chunk.message + '\n' }) 28 29 init([], function (err, code) { 30 t.ifError(err, 'init ran successfully') 31 t.notOk(code, 'exited without issue') 32 t.notSimilar(log, /written successfully/, 'no success message written') 33 t.similar(log, /canceled/, 'alerted that init was canceled') 34 35 t.end() 36 }) 37 }) 38}) 39