Skip to content

Commit 6026829

Browse files
authored
Fix node version detection to handle non-numeric patch version. NFC (#19061)
For example nightly builds of node report something like: v20.0.0-v8-canary202302081604228b65
1 parent 1320828 commit 6026829

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ jobs:
589589
other.test_gen_struct_info
590590
other.test_native_call_before_init
591591
other.test_node_unhandled_rejection
592+
other.test_min_node_version
592593
other.test_node_emscripten_num_logical_cores
593594
core2.test_pthread_create
594595
core2.test_i64_invoke_bigint

src/shell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ if (ENVIRONMENT_IS_NODE) {
182182
#if ASSERTIONS
183183
var nodeVersion = process.versions.node;
184184
var numericVersion = nodeVersion.split('.').slice(0, 3);
185-
numericVersion = (numericVersion[0] * 10000) + (numericVersion[1] * 100) + numericVersion[2] * 1;
185+
numericVersion = (numericVersion[0] * 10000) + (numericVersion[1] * 100) + (numericVersion[2].split('-')[0] * 1);
186186
var minVersion = {{{ MIN_NODE_VERSION }}};
187187
if (numericVersion < {{{ MIN_NODE_VERSION }}}) {
188188
throw new Error('This emscripten-generated code requires node {{{ formattedMinNodeVersion() }}} (detected v' + nodeVersion + ')');

test/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13270,7 +13270,7 @@ def test_min_node_version(self):
1327013270
node_version = shared.check_node_version()
1327113271
node_version = '.'.join(str(x) for x in node_version)
1327213272
self.set_setting('MIN_NODE_VERSION', 210000)
13273-
expected = 'This emscripten-generated code requires node v21.0.0 (detected v%s)' % node_version
13273+
expected = 'This emscripten-generated code requires node v21.0.0 (detected v%s' % node_version
1327413274
self.do_runf(test_file('hello_world.c'), expected, assert_returncode=NON_ZERO)
1327513275

1327613276
def test_deprecated_macros(self):

0 commit comments

Comments
 (0)