Fix JS build on Windows (#1648)

Summary:

Node made a breaking change in a security release for 18/20 where `spawn()` no longer loads `.bat` files by default. 69ffc6d50d. Execute command in shell.

Differential Revision: D56230965
This commit is contained in:
Nick Gerleman
2024-04-17 00:30:18 -07:00
committed by Facebook GitHub Bot
parent cd4a1b8cf6
commit 362633ac78

View File

@@ -168,9 +168,9 @@ function installEmsdkTask() {
{stdio: 'inherit'}, {stdio: 'inherit'},
); );
await spawn(emsdkBin, ['install', emsdkVersion], {stdio: 'inherit'}); await spawnShell(emsdkBin, ['install', emsdkVersion], {stdio: 'inherit'});
await spawn(emsdkBin, ['activate', emsdkVersion], { await spawnShell(emsdkBin, ['activate', emsdkVersion], {
stdio: logger.enableVerbose ? 'inherit' : 'ignore', stdio: logger.enableVerbose ? 'inherit' : 'ignore',
}); });
}; };
@@ -216,7 +216,7 @@ function emcmakeGenerateTask() {
]; ];
logger.info(['emcmake', ...args].join(' ')); logger.info(['emcmake', ...args].join(' '));
return spawn(emcmakeBin, args, { return spawnShell(emcmakeBin, args, {
stdio: logger.enableVerbose ? 'inherit' : 'ignore', stdio: logger.enableVerbose ? 'inherit' : 'ignore',
}); });
}; };
@@ -234,7 +234,7 @@ function cmakeBuildTask(opts) {
]; ];
logger.info(['cmake', ...args].join(' ')); logger.info(['cmake', ...args].join(' '));
return spawn(cmake, args, {stdio: 'inherit'}); return spawnShell(cmake, args, {stdio: 'inherit'});
}; };
} }
@@ -246,8 +246,13 @@ function clangFormatTask(opts) {
]; ];
logger.info(['clang-format', ...args].join(' ')); logger.info(['clang-format', ...args].join(' '));
return spawn(node, [require.resolve('clang-format'), ...args], { return spawnShell(node, [require.resolve('clang-format'), ...args], {
stdio: 'inherit', stdio: 'inherit',
}); });
}; };
} }
function spawnShell(cmd, args, opts) {
// https://github.com/nodejs/node/issues/52554
return spawn(cmd, args, {...opts, shell: true});
}