Skip to content

Commit 508cfb7

Browse files
committed
fixup! fix(config): don't overwrite react-native.config.js if it may be configured
1 parent 93961d4 commit 508cfb7

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

scripts/configure.mjs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,14 @@ export function mergeConfig(lhs, rhs) {
110110

111111
/**
112112
* Returns whether `react-native.config.js` needs to be updated.
113-
* @param {string} packagePath
113+
* @param {string} configPath
114114
* @returns {boolean}
115115
*/
116-
function shouldUpdateReactNativeConfig(packagePath, fs = nodefs) {
117-
const configPath = path.join(packagePath, "react-native.config.js");
116+
function shouldUpdateReactNativeConfig(configPath, fs = nodefs) {
117+
if (!fs.existsSync(configPath)) {
118+
return true;
119+
}
120+
118121
const config = readTextFile(configPath, fs);
119122
return (
120123
!/["'`]react-native-test-app["'`]/.test(config) ||
@@ -681,7 +684,8 @@ export function configure(params, fs = nodefs) {
681684
const templateFiles = Object.entries(files).filter(([filename]) => {
682685
switch (filename) {
683686
case "react-native.config.js": {
684-
const needsUpdate = shouldUpdateReactNativeConfig(packagePath);
687+
const configPath = path.join(packagePath, filename);
688+
const needsUpdate = shouldUpdateReactNativeConfig(configPath);
685689
if (!needsUpdate) {
686690
warn(
687691
`skipped modifying '${filename}' because it may already be configured for 'react-native-test-app'`

test/android/gradle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async function makeProject(
7373
init: true,
7474
});
7575

76-
await writeAllFiles(files, packagePath);
76+
await writeAllFiles(Object.entries(files), packagePath);
7777

7878
try {
7979
await fsp.symlink(

0 commit comments

Comments
 (0)