Skip to content

Commit e222452

Browse files
authored
fix: cannot find react-native-test-app when Metro starts (#788)
1 parent 54f5c9a commit e222452

File tree

3 files changed

+35
-28
lines changed

3 files changed

+35
-28
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"react-native": "^0.66.0-0",
8989
"react-native-builder-bob": "^0.18.0",
9090
"react-native-macos": "^0.66.0-0",
91-
"react-native-test-app": "^1.2.1",
91+
"react-native-test-app": "^1.3.4",
9292
"react-native-web": "^0.17.0",
9393
"react-native-windows": "^0.66.0-0",
9494
"react-test-renderer": "17.0.2",

react-native.config.js

+30-23
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
1-
const fs = require('fs');
2-
const path = require('path');
3-
const {
4-
androidManifestPath,
5-
iosProjectPath,
6-
windowsProjectPath,
7-
} = require('react-native-test-app');
1+
const project = (() => {
2+
const fs = require('fs');
3+
const path = require('path');
4+
try {
5+
const {
6+
androidManifestPath,
7+
iosProjectPath,
8+
windowsProjectPath,
9+
} = require('react-native-test-app');
10+
return {
11+
android: {
12+
sourceDir: path.join('example', 'android'),
13+
manifestPath: androidManifestPath(
14+
path.join(__dirname, 'example', 'android')
15+
),
16+
},
17+
ios: {
18+
project: iosProjectPath('example/ios'),
19+
},
20+
windows: fs.existsSync('example/windows/AsyncStorageExample.sln') && {
21+
sourceDir: path.join('example', 'windows'),
22+
solutionFile: 'AsyncStorageExample.sln',
23+
project: windowsProjectPath(path.join(__dirname, 'example', 'windows')),
24+
},
25+
};
26+
} catch (_) {
27+
return undefined;
28+
}
29+
})();
830

931
module.exports = {
1032
dependencies: {
@@ -35,20 +57,5 @@ module.exports = {
3557
},
3658
},
3759
},
38-
project: {
39-
android: {
40-
sourceDir: path.join('example', 'android'),
41-
manifestPath: androidManifestPath(
42-
path.join(__dirname, 'example', 'android')
43-
),
44-
},
45-
ios: {
46-
project: iosProjectPath('example/ios'),
47-
},
48-
windows: fs.existsSync('example/windows/AsyncStorageExample.sln') && {
49-
sourceDir: path.join('example', 'windows'),
50-
solutionFile: 'AsyncStorageExample.sln',
51-
project: windowsProjectPath(path.join(__dirname, 'example', 'windows')),
52-
},
53-
},
60+
...(project ? { project } : undefined),
5461
};

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -11224,10 +11224,10 @@ react-native-macos@^0.66.0-0:
1122411224
whatwg-fetch "^3.0.0"
1122511225
ws "^6.1.4"
1122611226

11227-
react-native-test-app@^1.2.1:
11228-
version "1.2.1"
11229-
resolved "https://registry.yarnpkg.com/react-native-test-app/-/react-native-test-app-1.2.1.tgz#1dcf1b3be57689b185e019eced91223d274bbe2e"
11230-
integrity sha512-+M0cps3k95JNdCvcrq2sXmblAOzG/Zv/6xU100kRS/wn5lL/3MHTkKq/0+BKiLB/ov5iHozGcB+Sn3FqezTuhw==
11227+
react-native-test-app@^1.3.4:
11228+
version "1.3.4"
11229+
resolved "https://registry.yarnpkg.com/react-native-test-app/-/react-native-test-app-1.3.4.tgz#d828620e93a8400c4502d1c15f7282f8922c3e47"
11230+
integrity sha512-+tdvSAXyKnpzq1EnILwMFS8AIETDW/Sahc+gaN4D9kQ0vB1C/OC0sC/ily5GMi1PokQI41xNktqOvq/V+Q4leA==
1123111231
dependencies:
1123211232
ajv "^8.0.0"
1123311233
chalk "^4.1.0"

0 commit comments

Comments
 (0)