Skip to content

Commit ed4f5f4

Browse files
committed
Fix expo#234
1 parent b2cb7c8 commit ed4f5f4

File tree

3 files changed

+52
-20
lines changed

3 files changed

+52
-20
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 1.3.1 (September 2, 2017)
2+
3+
#### Bug Fixes
4+
5+
* Fix an issue where `stdout` is null when validating inotify watches in some rare cases that I don't understand yet. (https://github.com/react-community/create-react-native-app/issues/234)
6+
7+
#### Committers
8+
9+
* brentvatne
10+
111
## 1.3.0 (August 28, 2017)
212

313
#### Bug Fixes

react-native-scripts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-scripts",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Configuration and scripts for Create React Native App.",
55
"license": "BSD-3-Clause",
66
"keywords": [

react-native-scripts/src/util/packager.js

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// @flow
22

3-
import { PackagerLogsStream, Project, ProjectSettings, ProjectUtils } from 'xdl';
3+
import {
4+
PackagerLogsStream,
5+
Project,
6+
ProjectSettings,
7+
ProjectUtils,
8+
} from 'xdl';
49

510
import spawn from 'cross-spawn';
611
import ProgressBar from 'progress';
@@ -40,7 +45,9 @@ async function cleanUpPackager(projectDir) {
4045
if (result === 'stopFailed') {
4146
// find RN packager pid, attempt to kill manually
4247
try {
43-
const { packagerPid } = await ProjectSettings.readPackagerInfoAsync(projectDir);
48+
const { packagerPid } = await ProjectSettings.readPackagerInfoAsync(
49+
projectDir
50+
);
4451
process.kill(packagerPid);
4552
} catch (e) {
4653
process.exit(1);
@@ -66,7 +73,9 @@ function run(onReady: () => ?any, options: Object = {}, isInteractive = false) {
6673
const watchmanExists = spawn.sync('which', ['watchman']).status === 0;
6774

6875
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();
7079
if (parseInt(watcherDetails.split(':')[1].trim()) < 5242880) {
7180
log.withTimestamp(
7281
`${chalk.red(`Unable to start server`)}
@@ -78,17 +87,25 @@ ${chalk.cyan(` sudo sysctl -w kern.maxfiles=5242880
7887
process.exit(1);
7988
}
8089
} 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
85106
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'
90108
);
91-
process.exit(1);
92109
}
93110
}
94111
}
@@ -151,12 +168,15 @@ ${chalk.cyan(` sudo sysctl -w fs.inotify.max_user_instances=1024
151168
let packagerLogsStream = new PackagerLogsStream({
152169
projectRoot: projectDir,
153170
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+
);
160180

161181
log.setBundleProgressBar(progressBar);
162182
},
@@ -178,7 +198,9 @@ ${chalk.cyan(` sudo sysctl -w fs.inotify.max_user_instances=1024
178198
log.withTimestamp(chalk.red(`Failed building JavaScript bundle`));
179199
} else {
180200
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+
);
182204
}
183205
}
184206
},

0 commit comments

Comments
 (0)