-
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: warn message on engine mismatch
- Fixed setting engine check warnings to each package - Added proper catching of package warnings during validation phase - Added tap test that validates print of engine warn msgs Fix: https://npm.community/t/engines-and-engines-strict-ignored/4792 PR-URL: #257 Credit: @ruyadorno Close: #257 Reviewed-by: @isaacs
- Loading branch information
Showing
4 changed files
with
74 additions
and
6 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,44 @@ | ||
'use strict' | ||
var test = require('tap').test | ||
var log = require('npmlog') | ||
var npm = require('../../lib/npm.js') | ||
var checkEngine = require('npm-install-checks').checkEngine | ||
|
||
var idealTree = { | ||
package: { | ||
name: 'a b c', | ||
version: '3.what' | ||
}, | ||
children: [{ | ||
name: 'faulty-engine', | ||
version: '0.0.1', | ||
children: [], | ||
engines: { | ||
node: '>=2.0.0' | ||
}, | ||
package: { | ||
name: 'faulty-engine', | ||
version: '0.0.1' | ||
} | ||
}], | ||
warnings: [] | ||
} | ||
|
||
test('setup', function (t) { | ||
const faultyEnginePkg = idealTree.children[0] | ||
checkEngine(faultyEnginePkg, '1.0.0', '1.0.0', false, false, (err, warn) => { | ||
t.ifError(err, 'check engine ran without issue') | ||
faultyEnginePkg.package.warnings = [warn] | ||
npm.load({}, t.end) | ||
}) | ||
}) | ||
|
||
test('validate-tree should collect warnings from modules', function (t) { | ||
log.disableProgress() | ||
var validateTree = require('../../lib/install/validate-tree.js') | ||
validateTree(idealTree, log.newGroup('validate'), function (er, a, b) { | ||
t.equal(idealTree.warnings[0].code, 'ENOTSUP', 'should have the correct error') | ||
t.match(idealTree.warnings[0].message, /Unsupported engine/, 'reason for optional failure in JSON') | ||
t.end() | ||
}) | ||
}) |