forked from npm/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: check that prepublish warning happens on npm i, too
PR-URL: npm/npm#14290 Credit: @zkat Reviewed-By: @othiym23
- Loading branch information
Showing
1 changed file
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
|
@@ -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') | ||
|