-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix package id in shrinkwrap lifecycle step output
Currently all logging related to shrinkwrap steps reports 'undefined' for the package in output and log messages. This is due to the package associated with the `idealTree` being recreated in the `savePackageJson()` method which precedes these steps. For now, just copy forward the `_id` attribute which lifecycle logging expects, but note that mutating `package` here is surprising. Fixes npm/npm#20756 PR-URL: #288 Credit: @bz2 Close: #288 Reviewed-by: @claudiahdz
- Loading branch information
1 parent
36e6c01
commit 1961c93
Showing
4 changed files
with
47 additions
and
0 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
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
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
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var fs = require('graceful-fs') | ||
var path = require('path') | ||
var test = require('tap').test | ||
var common = require('../common-tap.js') | ||
var pkg = common.pkg | ||
|
||
test('npm install execution order', function (t) { | ||
const packageJson = { | ||
name: 'life-test', | ||
version: '0.0.1', | ||
description: 'Test for npm install execution order', | ||
scripts: { | ||
install: 'true', | ||
preinstall: 'true', | ||
preshrinkwrap: 'true', | ||
postinstall: 'true', | ||
postshrinkwrap: 'true', | ||
shrinkwrap: 'true' | ||
} | ||
} | ||
fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify(packageJson), 'utf8') | ||
common.npm(['install', '--loglevel=error'], { cwd: pkg }, function (err, code, stdout, stderr) { | ||
if (err) throw err | ||
|
||
t.comment(stdout) | ||
t.comment(stderr) | ||
|
||
const steps = ['preinstall', 'install', 'postinstall', 'preshrinkwrap', 'shrinkwrap', 'postshrinkwrap'] | ||
const expectedLines = steps.map(function (step) { | ||
return '> ' + packageJson.name + '@' + packageJson.version + ' ' + step | ||
}) | ||
t.match(stdout, new RegExp(expectedLines.map(common.escapeForRe).join('(.|\n)*'))) | ||
t.end() | ||
}) | ||
}) |