From d115e7960d0a261c7e1e01c1af37f1502d05eb13 Mon Sep 17 00:00:00 2001 From: Peter Abbondanzo Date: Wed, 2 Dec 2026 11:37:08 -0800 Subject: [PATCH] Fix Windows warnings in yarn android-api-build Summary: On Windows, `yarn android-api-build` and `yarn android-api-validate` work but print noise: - Node 24 warns `DEP0190` on every run, because the Gradle wrapper (`gradlew.bat`) is started with `shell: true` plus a separate argument list, which Node only concatenates. The script now passes cmd.exe a single, quoted command line, so arguments with spaces still arrive intact. - When the API changed, `git diff --no-index` printed "LF will be replaced by CRLF" warnings under Git for Windows' default `core.autocrlf=true`. The diff now runs with `core.autocrlf=false`; the output is unchanged otherwise. Changelog: [Internal] Differential Revision: D135705049 --- scripts/android-api/build-android-api.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/scripts/android-api/build-android-api.js b/scripts/android-api/build-android-api.js index 337e4792bd7..f124d135039 100644 --- a/scripts/android-api/build-android-api.js +++ b/scripts/android-api/build-android-api.js @@ -36,17 +36,17 @@ function generateWithGradle(outputFile /*: string */) /*: number */ { REPO_ROOT, process.platform === 'win32' ? 'gradlew.bat' : 'gradlew', ); - // cmd.exe runs gradlew.bat and splits unquoted arguments on spaces. - const quote = (arg /*: string */) => - process.platform === 'win32' ? `"${arg}"` : arg; - const {status, error} = spawnSync( - quote(gradlew), - [ - ':packages:react-native:ReactAndroid:publicApiDump', - quote(`-PpublicApiDumpFile=${outputFile}`), - ], - {cwd: REPO_ROOT, stdio: 'inherit', shell: process.platform === 'win32'}, - ); + const task = ':packages:react-native:ReactAndroid:publicApiDump'; + const property = `-PpublicApiDumpFile=${outputFile}`; + const options = {cwd: REPO_ROOT, stdio: 'inherit'}; + // gradlew.bat only runs through cmd.exe, which takes one command line. + const {status, error} = + process.platform === 'win32' + ? spawnSync(`"${gradlew}" ${task} "${property}"`, { + ...options, + shell: true, + }) + : spawnSync(gradlew, [task, property], options); if (error != null) { console.error(`Failed to run ${gradlew}: ${error.message}`); return 1; @@ -283,6 +283,8 @@ function reportDifference( const {error} = spawnSync( 'git', [ + '-c', + 'core.autocrlf=false', '--no-pager', 'diff', '--no-index',