This repository has been archived by the owner on May 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
68 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
When you run the command, automagically it switches your node runtime | ||
based in the `engines.node` field declared at `package.json` | ||
of the project. | ||
|
||
If the `package.json` or `engines.node` doesn't exists, nothing happens. | ||
|
||
Usage | ||
$ nodengine | ||
|
||
Flags | ||
NODENGINE_INTERVAL | ||
Local cache for keep a list of all node versions to be resolved. | ||
|
||
The list, by default, is fetched after 5 days. | ||
|
||
You can setup a custom intervaling passing a milliseconds number. | ||
For example, if you want to force download the list of all node | ||
versions just pass a 0: | ||
|
||
NODENGINE_INTERVAL=0 nodengine | ||
|
||
Examples | ||
$ nodengine | ||
$ NODENGINE_INTERVAL=0 nodengine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict' | ||
|
||
var waterfall = require('async').waterfall | ||
var semver = require('semver') | ||
|
||
function _switch (nodeVersion) { | ||
var createSwitcher = require('./switcher') | ||
var config = require('./config') | ||
|
||
var tasks = [ | ||
function loadConfig (next) { | ||
return config(next) | ||
}, | ||
function getSwitcher (versions, next) { | ||
var currentVersion = process.versions.node | ||
var maxSatisfyVersion = semver.maxSatisfying(versions, nodeVersion) | ||
var switcher = createSwitcher(maxSatisfyVersion, currentVersion) | ||
|
||
switcher.getBin(function (err, bin) { | ||
return next(err, switcher, bin) | ||
}) | ||
} | ||
] | ||
|
||
waterfall(tasks, function (err, switcher, bin) { | ||
if (err) throw err | ||
if (bin) return switcher.spawn(bin) | ||
}) | ||
} | ||
|
||
module.exports = _switch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters