From f697b5ad5c0fa841650a6d67a955ce4b53550727 Mon Sep 17 00:00:00 2001 From: Sam Zhou Date: Tue, 22 Jul 2025 16:18:26 -0700 Subject: [PATCH] Make functions async and add await to prepare for prettier v3 upgrade: 6/n (#52770) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52770 Prettier v3 has an async API. This diff adds in async and await ahead of the upgrade to prepare for the API change. Changelog: [Internal] Reviewed By: pieterv Differential Revision: D78752906 fbshipit-source-id: 2deeecfc283be30fd0840b2a089604f4e6804af5 --- packages/react-native-codegen/scripts/build.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/react-native-codegen/scripts/build.js b/packages/react-native-codegen/scripts/build.js index 16a70ff7036..c8a5c6350f1 100644 --- a/packages/react-native-codegen/scripts/build.js +++ b/packages/react-native-codegen/scripts/build.js @@ -58,7 +58,7 @@ function getBuildPath(file, buildFolder) { return path.resolve(pkgBuildPath, relativeToSrcPath); } -function buildFile(file, silent) { +async function buildFile(file, silent) { const destPath = getBuildPath(file, BUILD_DIR); fs.mkdirSync(path.dirname(destPath), {recursive: true}); @@ -82,7 +82,7 @@ function buildFile(file, silent) { '\n', ); } else { - const transformed = prettier.format( + const transformed = await prettier.format( babel.transformFileSync(file, {}).code, { ...prettierConfig, @@ -111,6 +111,8 @@ const files = glob.sync(pattern, {nodir: true}); process.stdout.write(fixedWidth(`${path.basename(PACKAGE_DIR)}\n`)); -files.forEach(file => buildFile(file, !process.argv.includes('--verbose'))); - -process.stdout.write(`[ ${styleText('green', 'OK')} ]\n`); +Promise.all( + files.map(file => buildFile(file, !process.argv.includes('--verbose'))), +).then(() => { + process.stdout.write(`[ ${styleText('green', 'OK')} ]\n`); +});