Skip to content

Commit

Permalink
fixup! win: allow skipping the supported platform check
Browse files Browse the repository at this point in the history
  • Loading branch information
joaocgreis committed May 21, 2020
1 parent 4ebe1fc commit 9e2c90f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
5 changes: 3 additions & 2 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -1341,8 +1341,9 @@ Overriding this value to an empty string (`''`) will use the built-in REPL.
added: REPLACEME
-->

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

### `NODE_TLS_REJECT_UNAUTHORIZED=value`

Expand Down
16 changes: 11 additions & 5 deletions src/node_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,24 @@
#include <WinError.h>

#define SKIP_CHECK_VAR "NODE_SKIP_PLATFORM_CHECK"
#define SKIP_CHECK_SIZE 1
#define SKIP_CHECK_VALUE "1"

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

Expand Down

0 comments on commit 9e2c90f

Please sign in to comment.