Skip to content

Commit 22e28d9

Browse files
committed
Use RCT_SCRIPT_OUTPUT_DIR env var to find autolinking.json output too
1 parent 5027375 commit 22e28d9

File tree

1 file changed

+15
-9
lines changed
  • packages/react-native/scripts/codegen/generate-artifacts-executor

1 file changed

+15
-9
lines changed

packages/react-native/scripts/codegen/generate-artifacts-executor/utils.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,26 @@ function cleanupEmptyFilesAndFolders(filepath /*: string */) {
100100
function readGeneratedAutolinkingOutput(
101101
baseOutputPath /*: string */,
102102
) /*: $FlowFixMe */ {
103-
// NOTE: Generated by scripts/cocoapods/autolinking.rb in list_native_modules (called by use_native_modules)
104-
const autolinkingGeneratedPath = path.resolve(
103+
const basePathOptions = [
104+
// The `outputDir` may not be set correctly if it's set to the a temporary output directory
105+
process.env.RCT_SCRIPT_OUTPUT_DIR,
106+
// NOTE: Generated by scripts/cocoapods/autolinking.rb in list_native_modules (called by use_native_modules)
105107
baseOutputPath,
106-
'build/generated/autolinking/autolinking.json',
107-
);
108-
if (fs.existsSync(autolinkingGeneratedPath)) {
109-
// $FlowFixMe[unsupported-syntax]
110-
return require(autolinkingGeneratedPath);
111-
} else {
108+
].filter((item) => !!item);
109+
for (const basePath of basePathOptions) {
110+
const autolinkingGeneratedPath = path.resolve(
111+
basePath,
112+
'build/generated/autolinking/autolinking.json',
113+
);
114+
if (fs.existsSync(autolinkingGeneratedPath)) {
115+
// $FlowFixMe[unsupported-syntax]
116+
return require(autolinkingGeneratedPath);
117+
}
112118
codegenLog(
113119
`Could not find generated autolinking output at: ${autolinkingGeneratedPath}`,
114120
);
115-
return null;
116121
}
122+
return null;
117123
}
118124

119125
function readReactNativeConfig(

0 commit comments

Comments
 (0)