Skip to content

Commit

Permalink
make default --save semver option configurable
Browse files Browse the repository at this point in the history
Implementing suggestion in npm/npm#4713

You can return old npm behaviour in config:
yapm config set save-range '~'
yapm install --save express

Or just use range shortcut in the command line:
yapm install --save --range='~' express

Available options for save-range are:
 - "~"
 - "^"
 - ">="
 - "<="
 - "=" - no range (exact)
  • Loading branch information
rlidwka committed Mar 4, 2014
1 parent 59978ca commit 62a97cd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,13 @@ function save (where, installed, tree, pretty, hasArguments, cb) {
if (u && u.protocol) w[1] = t.from
return w
}).reduce(function (set, k) {
var range = npm.config.get('save-exact') || npm.config.get('save-range')
if (typeof(range) === 'boolean' || range === '=') range = ''
else if (range === '>' || range === '<') range = range + '='

var rangeDescriptor = semver.valid(k[1], true) &&
semver.gte(k[1], "0.1.0", true) &&
!npm.config.get("save-exact")
? "^" : ""
semver.gte(k[1], "0.1.0", true)
? range : ""
set[k[0]] = rangeDescriptor + k[1]
return set
}, {})
Expand Down
8 changes: 7 additions & 1 deletion node_modules/init-package-json/default-input.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions node_modules/npmconf/config-defs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 62a97cd

Please sign in to comment.