Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check save-prefix satisfies requested install version range #193

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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