Skip to content

Commit 39fb7c0

Browse files
kvakilNo9
authored andcommitted
fix getting current Node.js version
Without this, `nodejsVersion()` returns `[NaN]` when using a release build of Node.js.
1 parent f9580d8 commit 39fb7c0

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

test/common.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,9 @@ Session.prototype.hasSymbol = function hasSymbol(symbol, callback) {
342342
};
343343

344344
function nodejsVersion() {
345-
const version = process.version.substring(1, process.version.indexOf('-'));
345+
const candidateIndex = process.version.indexOf('-');
346+
const endIndex = candidateIndex != -1 ? candidateIndex : process.version.length;
347+
const version = process.version.substring(1, endIndex);
346348
const versionArray = version.split('.').map(s => Number(s));
347349
return versionArray;
348350
}

0 commit comments

Comments
 (0)