Skip to content

Commit d636cdd

Browse files
committed
Run react-native cli with wrapper
RN 0.42 no more accept 'root' option. RN 0.42 requires absolute paths for 'projectRoots' option.
1 parent 572d1f2 commit d636cdd

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "lib/index.js",
66
"scripts": {
77
"start": "npm run start-sample --",
8-
"start-sample": "react-native start --root samples/SampleApp",
8+
"start-sample": "node rn-wrapper.js start --projectRoots samples/SampleApp,.",
99
"run-sample-android": "react-native run-android --root samples/SampleApp",
1010
"run-sample-ios": "react-native run-ios --project-path samples/SampleApp/ios"
1111
},

rn-wrapper.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
const path = require('path')
3+
4+
// modify paths to be absolute
5+
const PATH_ARG_RE = /^--?(root|projectRoots)$/
6+
const argv = process.argv
7+
for (let i = 2; i < argv.length; ++i) {
8+
if (PATH_ARG_RE.test(argv[i - 1])) {
9+
argv[i] = argv[i].split(',').map(function (p) {
10+
return path.resolve(__dirname, p)
11+
}).join(',')
12+
}
13+
}
14+
15+
const cli = require('react-native/cli')
16+
cli.run()

0 commit comments

Comments
 (0)