Skip to content

Commit

Permalink
fix: allow pre-release versions of npm and node
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Sep 30, 2019
1 parent ab92033 commit 893b181
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Expand Up @@ -7,9 +7,10 @@ exports.checkEngine = checkEngine
function checkEngine (target, npmVer, nodeVer, force, strict, cb) {
var nodev = force ? null : nodeVer
var eng = target.engines
var opt = { includePrerelease: true }
if (!eng) return cb()
if (nodev && eng.node && !semver.satisfies(nodev, eng.node) ||
eng.npm && !semver.satisfies(npmVer, eng.npm)) {
if (nodev && eng.node && !semver.satisfies(nodev, eng.node, opt) ||
eng.npm && !semver.satisfies(npmVer, eng.npm, opt)) {
var er = new Error(util.format('Unsupported engine for %s: wanted: %j (current: %j)',
target._id, eng, {node: nodev, npm: npmVer}))
er.code = 'ENOTSUP'
Expand Down
9 changes: 9 additions & 0 deletions test/check-engine.js
Expand Up @@ -60,3 +60,12 @@ test('no engine', function (t) {
t.end()
})
})

test('npm prerelease', function (t) {
var target = { engines: { node: '>=0.8', npm: '>=1.2.3' } }
c(target, '69.420.0-yolo', '69.420.0-yolo', true, true, function (err, warn) {
t.notOk(err, 'returns no error')
t.notOk(warn, 'returns no warning')
t.end()
})
})

0 comments on commit 893b181

Please sign in to comment.