Skip to content

Commit 9e2c90f

Browse files
committed
fixup! win: allow skipping the supported platform check
1 parent 4ebe1fc commit 9e2c90f

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

doc/api/cli.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,8 +1341,9 @@ Overriding this value to an empty string (`''`) will use the built-in REPL.
13411341
added: REPLACEME
13421342
-->
13431343

1344-
Skips the check for a supported platform that happens during Node.js startup.
1345-
Using this might lead to issues during execution.
1344+
If `value` equals `'1'`, the check for a supported platform is skipped during
1345+
Node.js startup. Node.js might not execute correctly. Any issues encountered
1346+
on unsupported platforms will not be fixed.
13461347

13471348
### `NODE_TLS_REJECT_UNAUTHORIZED=value`
13481349

src/node_main.cc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,24 @@
2828
#include <WinError.h>
2929

3030
#define SKIP_CHECK_VAR "NODE_SKIP_PLATFORM_CHECK"
31+
#define SKIP_CHECK_SIZE 1
32+
#define SKIP_CHECK_VALUE "1"
3133

3234
int wmain(int argc, wchar_t* wargv[]) {
3335
// Windows Server 2012 (not R2) is supported until 10/10/2023, so we allow it
3436
// to run in the experimental support tier.
37+
char buf[SKIP_CHECK_SIZE + 1];
3538
if (!IsWindows8Point1OrGreater() &&
3639
!(IsWindowsServer() && IsWindows8OrGreater()) &&
37-
GetEnvironmentVariableA(SKIP_CHECK_VAR, nullptr, 0) == 0) {
40+
(GetEnvironmentVariableA(SKIP_CHECK_VAR, buf, sizeof(buf)) !=
41+
SKIP_CHECK_SIZE ||
42+
strncmp(buf, SKIP_CHECK_VALUE, SKIP_CHECK_SIZE + 1) != 0)) {
3843
fprintf(stderr, "This application is only supported on Windows 8.1, "
39-
"Windows Server 2012 R2, or higher.\n"
40-
"If the environment varaible " SKIP_CHECK_VAR
41-
" is defined this check is skipped, but Node.js might "
42-
"not execute correctly.");
44+
"Windows Server 2012 R2, or\nhigher.\n"
45+
"Setting the " SKIP_CHECK_VAR " environment variable "
46+
"to 1 skips this\ncheck, but Node.js might not execute "
47+
"correctly. Any issues encountered on\nunsupported "
48+
"platforms will not be fixed.");
4349
exit(ERROR_EXE_MACHINE_TYPE_MISMATCH);
4450
}
4551

0 commit comments

Comments
 (0)