Skip to content

Commit

Permalink
Fix nodists#181: Don't set any version without checking if its valid
Browse files Browse the repository at this point in the history
  • Loading branch information
osher authored and marcelklehr committed Dec 5, 2016
1 parent e37fe3f commit 91e7555
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,23 +356,26 @@ else if (command.match(/^local$/i) && argv[1]) {
// GLOBAL globally use the specified node version
else if (command.match(/^global$/i) && argv[1] || argv[0] && !argv[1]) {
spec = argv[1] || argv[0];
n.setGlobal(spec, function(err) {
if(err) abort(err.message+'. Sorry.');
console.log(spec);
n.resolveVersionLocally(spec, function(er, found) {
if(found) {
exit();
}
n.resolveVersion(spec, function(er, version) {
console.log("Installing "+version)
n.install(version, function(er) {
if(er) return abort(er.message+'. Sorry.')
console.log(spec);
n.resolveVersionLocally(spec, function(er, found) {
if(found) {
return n.setGlobal(spec, function(err) {
if(err) abort(err.message+'. Sorry.')
exit(0, 'Default global pacakge update dsuccessful.')
})
}
n.resolveVersion(spec, function(er, version) {
if(er) return abort(er.message+'. Sorry.')
console.log("Installing "+version)
n.install(version, function(er) {
if(er) return abort(er.message+'. Sorry.')
n.setGlobal(spec, function(err) {
if(err) abort(err.message+'. Sorry.')
exit(0, 'Installation successful.')
})
})
})

});
})
}
// HELP display help for unknown cli parameters
else {
Expand Down

0 comments on commit 91e7555

Please sign in to comment.