1
1
// @flow
2
2
3
- import { PackagerLogsStream , Project , ProjectSettings , ProjectUtils } from 'xdl' ;
3
+ import {
4
+ PackagerLogsStream ,
5
+ Project ,
6
+ ProjectSettings ,
7
+ ProjectUtils ,
8
+ } from 'xdl' ;
4
9
5
10
import spawn from 'cross-spawn' ;
6
11
import ProgressBar from 'progress' ;
@@ -40,7 +45,9 @@ async function cleanUpPackager(projectDir) {
40
45
if ( result === 'stopFailed' ) {
41
46
// find RN packager pid, attempt to kill manually
42
47
try {
43
- const { packagerPid } = await ProjectSettings . readPackagerInfoAsync ( projectDir ) ;
48
+ const { packagerPid } = await ProjectSettings . readPackagerInfoAsync (
49
+ projectDir
50
+ ) ;
44
51
process . kill ( packagerPid ) ;
45
52
} catch ( e ) {
46
53
process . exit ( 1 ) ;
@@ -66,7 +73,9 @@ function run(onReady: () => ?any, options: Object = {}, isInteractive = false) {
66
73
const watchmanExists = spawn . sync ( 'which' , [ 'watchman' ] ) . status === 0 ;
67
74
68
75
if ( process . platform === 'darwin' && ! watchmanExists ) {
69
- const watcherDetails = spawn . sync ( 'sysctl' , [ 'kern.maxfiles' ] ) . stdout . toString ( ) ;
76
+ const watcherDetails = spawn
77
+ . sync ( 'sysctl' , [ 'kern.maxfiles' ] )
78
+ . stdout . toString ( ) ;
70
79
if ( parseInt ( watcherDetails . split ( ':' ) [ 1 ] . trim ( ) ) < 5242880 ) {
71
80
log . withTimestamp (
72
81
`${ chalk . red ( `Unable to start server` ) }
@@ -78,17 +87,25 @@ ${chalk.cyan(` sudo sysctl -w kern.maxfiles=5242880
78
87
process . exit ( 1 ) ;
79
88
}
80
89
} else if ( ! watchmanExists ) {
81
- const watcherDetails = spawn
82
- . sync ( 'sysctl' , [ 'fs.inotify.max_user_watches' ] )
83
- . stdout . toString ( ) ;
84
- if ( parseInt ( watcherDetails . split ( '=' ) [ 1 ] . trim ( ) ) < 12288 ) {
90
+ try {
91
+ const watcherDetails = spawn
92
+ . sync ( 'sysctl' , [ 'fs.inotify.max_user_watches' ] )
93
+ . stdout . toString ( ) ;
94
+ if ( parseInt ( watcherDetails . split ( '=' ) [ 1 ] . trim ( ) ) < 12288 ) {
95
+ log . withTimestamp (
96
+ `${ chalk . red ( `Unable to start server` ) }
97
+ See https://git.io/v5vcn for more information, either install watchman or run the following snippet:
98
+ ${ chalk . cyan ( ` sudo sysctl -w fs.inotify.max_user_instances=1024
99
+ sudo sysctl -w fs.inotify.max_user_watches=12288` ) } `
100
+ ) ;
101
+ process . exit ( 1 ) ;
102
+ }
103
+ } catch ( e ) {
104
+ // note(brentvatne): I'm not sure why stdout is null for some OS's
105
+ // https://github.com/react-community/create-react-native-app/issues/391
85
106
log . withTimestamp (
86
- `${ chalk . red ( `Unable to start server` ) }
87
- See https://git.io/v5vcn for more information, either install watchman or run the following snippet:
88
- ${ chalk . cyan ( ` sudo sysctl -w fs.inotify.max_user_instances=1024
89
- sudo sysctl -w fs.inotify.max_user_watches=12288` ) } `
107
+ 'Warning: Unable to run `sysctl fs.inotify.max_user_watches`. If you encounter issues, please refer to https://git.io/v5vcn'
90
108
) ;
91
- process . exit ( 1 ) ;
92
109
}
93
110
}
94
111
}
@@ -151,12 +168,15 @@ ${chalk.cyan(` sudo sysctl -w fs.inotify.max_user_instances=1024
151
168
let packagerLogsStream = new PackagerLogsStream ( {
152
169
projectRoot : projectDir ,
153
170
onStartBuildBundle : ( ) => {
154
- progressBar = new ProgressBar ( 'Building JavaScript bundle [:bar] :percent' , {
155
- total : 100 ,
156
- clear : true ,
157
- complete : '=' ,
158
- incomplete : ' ' ,
159
- } ) ;
171
+ progressBar = new ProgressBar (
172
+ 'Building JavaScript bundle [:bar] :percent' ,
173
+ {
174
+ total : 100 ,
175
+ clear : true ,
176
+ complete : '=' ,
177
+ incomplete : ' ' ,
178
+ }
179
+ ) ;
160
180
161
181
log . setBundleProgressBar ( progressBar ) ;
162
182
} ,
@@ -178,7 +198,9 @@ ${chalk.cyan(` sudo sysctl -w fs.inotify.max_user_instances=1024
178
198
log . withTimestamp ( chalk . red ( `Failed building JavaScript bundle` ) ) ;
179
199
} else {
180
200
let duration = endTime - startTime ;
181
- log . withTimestamp ( chalk . green ( `Finished building JavaScript bundle in ${ duration } ms` ) ) ;
201
+ log . withTimestamp (
202
+ chalk . green ( `Finished building JavaScript bundle in ${ duration } ms` )
203
+ ) ;
182
204
}
183
205
}
184
206
} ,
0 commit comments