Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions lib/auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ function findAutoVersionAsync(cwd) {
} catch (e) {
Error.throwIfNot(Error.ENOENT, e, 'Failed to read file: ' + versionFile);
}

// If we don't have a version string, try checking for an .nvmrc file
if (!versionString && !settings.disableNvmrc) {
versionFile = path.join(dir, '.nvmrc');
try {
versionString = fs.readFileSync(versionFile, 'utf8').trim();
} catch (_) { }
}

if (versionString) {
try {
version = NodeVersion.parse(versionString);
Expand Down
3 changes: 3 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ function doCommand(args) {

case 'add':
if (help) return help('add');
if (!args[1]) {
return require('./auto').findAutoVersionAsync();
}
version = parseVersion(args[1]);
return require('./addRemove').addAsync(version);

Expand Down