mirror of
https://github.com/react/react-native.git
synced 2026-09-28 13:23:09 +08:00
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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6c8bcad054
commit
f697b5ad5c
+7
-5
@@ -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`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user