Skip to content

Commit 4bc5df3

Browse files
author
Mariusz Pasinski
committed
refactor: simplify by using Object.values(); reuse absoluteModulePaths
1 parent 3de8033 commit 4bc5df3

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

packages/host/src/node/cli/link-modules.ts

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,10 @@ export async function linkModules({
6868
});
6969

7070
// Find absolute paths to xcframeworks
71-
const absoluteModulePaths = Object.entries(dependenciesByName).flatMap(
72-
([, dependency]) => {
73-
return dependency.modulePaths.map((modulePath) =>
74-
path.join(dependency.path, modulePath)
75-
);
76-
}
71+
const absoluteModulePaths = Object.values(dependenciesByName).flatMap(
72+
(dependency) => dependency.modulePaths.map(
73+
(modulePath) => path.join(dependency.path, modulePath)
74+
)
7775
);
7876

7977
if (hasDuplicateLibraryNames(absoluteModulePaths, naming)) {
@@ -82,28 +80,25 @@ export async function linkModules({
8280
}
8381

8482
return Promise.all(
85-
Object.entries(dependenciesByName).flatMap(([, dependency]) => {
86-
return dependency.modulePaths.map(async (modulePath) => {
87-
const originalPath = path.join(dependency.path, modulePath);
88-
try {
89-
return await linker({
90-
modulePath: originalPath,
91-
incremental,
92-
naming,
93-
platform,
94-
});
95-
} catch (error) {
96-
if (error instanceof SpawnFailure) {
97-
return {
98-
originalPath,
99-
skipped: false,
100-
failure: error,
101-
};
102-
} else {
103-
throw error;
104-
}
83+
absoluteModulePaths.map(async (originalPath) => {
84+
try {
85+
return await linker({
86+
modulePath: originalPath,
87+
incremental,
88+
naming,
89+
platform,
90+
});
91+
} catch (error) {
92+
if (error instanceof SpawnFailure) {
93+
return {
94+
originalPath,
95+
skipped: false,
96+
failure: error,
97+
};
98+
} else {
99+
throw error;
105100
}
106-
});
101+
}
107102
})
108103
);
109104
}

0 commit comments

Comments
 (0)