Skip to content

Commit 2d6d34f

Browse files
committed
Refactor createAppleFramework into an async function
1 parent 8b508ae commit 2d6d34f

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

packages/ferric/src/build.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ export const buildCommand = new Command("build")
238238

239239
if (appleLibraries.length > 0) {
240240
const libraryPaths = await combineLibraries(appleLibraries);
241-
const frameworkPaths = libraryPaths.map(createAppleFramework);
241+
const frameworkPaths = await Promise.all(
242+
libraryPaths.map(createAppleFramework),
243+
);
242244
const xcframeworkFilename = determineXCFrameworkFilename(
243245
frameworkPaths,
244246
xcframeworkExtension ? ".xcframework" : ".apple.node",

packages/host/src/node/prebuilds/apple.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type XCframeworkOptions = {
4545
autoLink: boolean;
4646
};
4747

48-
export function createAppleFramework(libraryPath: string) {
48+
export async function createAppleFramework(libraryPath: string) {
4949
assert(fs.existsSync(libraryPath), `Library not found: ${libraryPath}`);
5050
// Write a info.plist file to the framework
5151
const libraryName = path.basename(libraryPath, path.extname(libraryPath));
@@ -54,11 +54,11 @@ export function createAppleFramework(libraryPath: string) {
5454
`${libraryName}.framework`,
5555
);
5656
// Create the framework from scratch
57-
fs.rmSync(frameworkPath, { recursive: true, force: true });
58-
fs.mkdirSync(frameworkPath);
59-
fs.mkdirSync(path.join(frameworkPath, "Headers"));
57+
await fs.promises.rm(frameworkPath, { recursive: true, force: true });
58+
await fs.promises.mkdir(frameworkPath);
59+
await fs.promises.mkdir(path.join(frameworkPath, "Headers"));
6060
// Create an empty Info.plist file
61-
fs.writeFileSync(
61+
await fs.promises.writeFile(
6262
path.join(frameworkPath, "Info.plist"),
6363
createPlistContent({
6464
CFBundleDevelopmentRegion: "en",
@@ -75,8 +75,9 @@ export function createAppleFramework(libraryPath: string) {
7575
);
7676
const newLibraryPath = path.join(frameworkPath, libraryName);
7777
// TODO: Consider copying the library instead of renaming it
78-
fs.renameSync(libraryPath, newLibraryPath);
78+
await fs.promises.rename(libraryPath, newLibraryPath);
7979
// Update the name of the library
80+
// TODO: Make this call async
8081
cp.spawnSync("install_name_tool", [
8182
"-id",
8283
`@rpath/${libraryName}.framework/${libraryName}`,

0 commit comments

Comments
 (0)