Skip to content

Commit

Permalink
fix getting current Node.js version
Browse files Browse the repository at this point in the history
Without this, `nodejsVersion()` returns `[NaN]` when using a release
build of Node.js.
  • Loading branch information
kvakil committed Aug 16, 2022
1 parent 1924ea2 commit c4c7636
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ Session.prototype.hasSymbol = function hasSymbol(symbol, callback) {
};

function nodejsVersion() {
const version = process.version.substring(1, process.version.indexOf('-'));
const candidateIndex = process.version.indexOf('-');
const endIndex = candidateIndex != -1 ? candidateIndex : process.version.length;
const version = process.version.substring(1, endIndex);
const versionArray = version.split('.').map(s => Number(s));
return versionArray;
}
Expand Down

0 comments on commit c4c7636

Please sign in to comment.