Skip to content

Commit 7b562c3

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

File tree

1 file changed

+20
-12
lines changed
  • packages/react-native/scripts/codegen/generate-artifacts-executor

1 file changed

+20
-12
lines changed

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

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,28 @@ 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 outputPathCandidates = [
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 {
112-
codegenLog(
113-
`Could not find generated autolinking output at: ${autolinkingGeneratedPath}`,
114-
);
115-
return null;
108+
];
109+
for (const outputPathCandidate of outputPathCandidates) {
110+
if (outputPathCandidate != null && outputPathCandidate.length > 0) {
111+
const autolinkingGeneratedPath = path.resolve(
112+
outputPathCandidate,
113+
'build/generated/autolinking/autolinking.json',
114+
);
115+
if (fs.existsSync(autolinkingGeneratedPath)) {
116+
// $FlowFixMe[unsupported-syntax]
117+
return require(autolinkingGeneratedPath);
118+
}
119+
codegenLog(
120+
`Could not find generated autolinking output at: ${autolinkingGeneratedPath}`,
121+
);
122+
}
116123
}
124+
return null;
117125
}
118126

119127
function readReactNativeConfig(

0 commit comments

Comments
 (0)