File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,24 @@ function getEntryPoint() {
3535 return entry ;
3636}
3737
38+ function getReactNativeBin ( ) {
39+ const localBin = './node_modules/.bin/react-native' ;
40+ if ( fs . existsSync ( localBin ) ) return localBin ;
41+ try {
42+ const reactNativeDir = path . dirname (
43+ require . resolve ( 'react-native/package.json' )
44+ ) ;
45+ return path . join ( reactNativeDir , './cli.js' ) ;
46+ } catch ( e ) {
47+ console . error (
48+ chalk . red . bold (
49+ `React-native binary could not be located. Please report this issue with environment info to:\n`
50+ ) ,
51+ chalk . blue . bold ( `-> ${ require ( '../package.json' ) . bugs } ` )
52+ ) ;
53+ }
54+ }
55+
3856// Get (default) arguments
3957const baseDir = path . join ( os . tmpdir ( ) , 'react-native-bundle-visualizer' ) ;
4058const tmpDir = path . join ( baseDir , getAppName ( ) ) ;
@@ -92,7 +110,8 @@ if (expoTargetDeprecated) {
92110 ) ;
93111}
94112
95- const bundlePromise = execa ( './node_modules/.bin/react-native' , commands ) ;
113+ const reactNativeBin = getReactNativeBin ( ) ;
114+ const bundlePromise = execa ( reactNativeBin , commands ) ;
96115bundlePromise . stdout . pipe ( process . stdout ) ;
97116
98117// Upon bundle completion, run `source-map-explorer`
You can’t perform that action at this time.
0 commit comments