Skip to content

Commit

Permalink
check save-prefix satisfies requested version range
Browse files Browse the repository at this point in the history
  • Loading branch information
austinhc-ibm committed May 13, 2019
1 parent 656bce7 commit 3042e1a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/install/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,18 @@ function computeVersionSpec (tree, child) {
if (semver.valid(version, true) &&
semver.gte(version, '0.1.0', true) &&
!npm.config.get('save-exact')) {
rangeDescriptor = npm.config.get('save-prefix')
if (requested.type === 'range') {
// add save-prefix '^' or '~' only when the future candidates satisfies the
// requested range version spec
var futureVersion = semver.maxSatisfying([semver.inc(version, 'major'),
semver.inc(version, 'minor'), semver.inc(version, 'patch')],
npm.config.get('save-prefix') + version)
if (semver.satisfies(futureVersion, requested.fetchSpec)) {
rangeDescriptor = npm.config.get('save-prefix')
}
} else {
rangeDescriptor = npm.config.get('save-prefix')
}
}
if (requested.type === 'alias') {
rangeDescriptor = `npm:${requested.subSpec.name}@${rangeDescriptor}`
Expand Down

0 comments on commit 3042e1a

Please sign in to comment.