Skip to content

Commit

Permalink
fix: cannot find react-native-test-app when Metro starts (#788)
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 authored Mar 30, 2022
1 parent 54f5c9a commit e222452
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"react-native": "^0.66.0-0",
"react-native-builder-bob": "^0.18.0",
"react-native-macos": "^0.66.0-0",
"react-native-test-app": "^1.2.1",
"react-native-test-app": "^1.3.4",
"react-native-web": "^0.17.0",
"react-native-windows": "^0.66.0-0",
"react-test-renderer": "17.0.2",
Expand Down
53 changes: 30 additions & 23 deletions react-native.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
const fs = require('fs');
const path = require('path');
const {
androidManifestPath,
iosProjectPath,
windowsProjectPath,
} = require('react-native-test-app');
const project = (() => {
const fs = require('fs');
const path = require('path');
try {
const {
androidManifestPath,
iosProjectPath,
windowsProjectPath,
} = require('react-native-test-app');
return {
android: {
sourceDir: path.join('example', 'android'),
manifestPath: androidManifestPath(
path.join(__dirname, 'example', 'android')
),
},
ios: {
project: iosProjectPath('example/ios'),
},
windows: fs.existsSync('example/windows/AsyncStorageExample.sln') && {
sourceDir: path.join('example', 'windows'),
solutionFile: 'AsyncStorageExample.sln',
project: windowsProjectPath(path.join(__dirname, 'example', 'windows')),
},
};
} catch (_) {
return undefined;
}
})();

module.exports = {
dependencies: {
Expand Down Expand Up @@ -35,20 +57,5 @@ module.exports = {
},
},
},
project: {
android: {
sourceDir: path.join('example', 'android'),
manifestPath: androidManifestPath(
path.join(__dirname, 'example', 'android')
),
},
ios: {
project: iosProjectPath('example/ios'),
},
windows: fs.existsSync('example/windows/AsyncStorageExample.sln') && {
sourceDir: path.join('example', 'windows'),
solutionFile: 'AsyncStorageExample.sln',
project: windowsProjectPath(path.join(__dirname, 'example', 'windows')),
},
},
...(project ? { project } : undefined),
};
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11224,10 +11224,10 @@ react-native-macos@^0.66.0-0:
whatwg-fetch "^3.0.0"
ws "^6.1.4"

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

0 comments on commit e222452

Please sign in to comment.