From af57b2164d1fd9069feec441a5ea95991a6fcac9 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Wed, 17 Apr 2024 03:03:02 -0700 Subject: [PATCH] Fix JS build on Windows (#1648) Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1648 Node made a breaking change in a security release for 18/20 where `spawn()` no longer loads `.bat` files by default. https://github.com/nodejs/node/commit/69ffc6d50dbd9d7d0257f5b9b403026e1aa205ee. Execute command in shell. Reviewed By: javache Differential Revision: D56230965 fbshipit-source-id: 52e9bd8a76664bd07ea25b6355ac54fcb24cbb9a --- javascript/just.config.cjs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/javascript/just.config.cjs b/javascript/just.config.cjs index 8373808d..9533c2ac 100644 --- a/javascript/just.config.cjs +++ b/javascript/just.config.cjs @@ -168,9 +168,9 @@ function installEmsdkTask() { {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', }); }; @@ -216,7 +216,7 @@ function emcmakeGenerateTask() { ]; logger.info(['emcmake', ...args].join(' ')); - return spawn(emcmakeBin, args, { + return spawnShell(emcmakeBin, args, { stdio: logger.enableVerbose ? 'inherit' : 'ignore', }); }; @@ -234,7 +234,7 @@ function cmakeBuildTask(opts) { ]; 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(' ')); - return spawn(node, [require.resolve('clang-format'), ...args], { + return spawnShell(node, [require.resolve('clang-format'), ...args], { stdio: 'inherit', }); }; } + +function spawnShell(cmd, args, opts) { + // https://github.com/nodejs/node/issues/52554 + return spawn(cmd, args, {...opts, shell: true}); +}