Skip to content

Commit

Permalink
test: check that prepublish warning happens on npm i, too
Browse files Browse the repository at this point in the history
PR-URL: npm/npm#14290
Credit: @zkat
Reviewed-By: @othiym23
  • Loading branch information
zkat committed Oct 20, 2016
1 parent 4c2a948 commit a55bd65
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions test/tap/prepublish.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test('setup', function (t) {
}
})

test('test', function (t) {
test('prepublish deprecation warning on `npm pack`', function (t) {
var env = {
'npm_config_cache': cache,
'npm_config_tmp': tmp,
Expand Down Expand Up @@ -68,11 +68,45 @@ test('test', function (t) {
'ok\\r?\\n' +
'npm-test-prepublish-1.2.5.tgz', 'ig')

t.ok(c.match(regex))
t.match(c, regex)
t.end()
})
})

test('prepublish deprecation warning on `npm install`', function (t) {
var env = {
'npm_config_cache': cache,
'npm_config_tmp': tmp,
'npm_config_prefix': pkg,
'npm_config_global': 'false'
}

for (var i in process.env) {
if (!/^npm_config_/.test(i)) {
env[i] = process.env[i]
}
}

common.npm([
'install',
'--loglevel', 'warn'
], { cwd: pkg, env: env }, function (err, code, stdout, stderr) {
t.equal(code, 0, 'pack finished successfully')
t.ifErr(err, 'pack finished successfully')

t.match(stderr, /`prepublish` scripts will run only for `npm publish`/)
var c = stdout.trim()
var regex = new RegExp('' +
'> [email protected] prepublish [^\\r\\n]+\\r?\\n' +
'> echo ok\\r?\\n' +
'\\r?\\n' +
'ok' +
'', 'ig')

t.match(c, regex)
t.end()
})
})
test('cleanup', function (t) {
cleanup()
t.pass('cleaned up')
Expand Down

0 comments on commit a55bd65

Please sign in to comment.