Skip to content

Commit 14784ae

Browse files
committed
Add process.stdin On End Explanation
1 parent c116b90 commit 14784ae

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

packages/react-scripts/scripts/start.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
4242
process.exit(1);
4343
}
4444

45+
// Issue: https://github.com/facebookincubator/create-react-app/issues/1753
46+
// The below lines are added to make sure that this process is
47+
// exited when stdin is ended. The consequence of not doing this means
48+
// that all watch processes will stay running despite the process that spawned
49+
// them being closed.
4550
process.stdin.on('end', function() {
4651
process.exit(0);
4752
});

packages/react-scripts/scripts/test.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,20 @@ const jest = require('jest');
2323
const argv = process.argv.slice(2);
2424

2525
// Watch unless on CI or in coverage mode
26+
// Exit process when stdin ends only when watch mode enabled
2627
if (!process.env.CI && argv.indexOf('--coverage') < 0) {
2728
argv.push('--watch');
29+
30+
// Issue: https://github.com/facebookincubator/create-react-app/issues/1753
31+
// The below lines are added to make sure that this process is
32+
// exited when stdin is ended. The consequence of not doing this means
33+
// that all watch processes will stay running despite the process that spawned
34+
// them being closed.
35+
36+
process.stdin.on('end', function() {
37+
process.exit(0);
38+
});
39+
process.stdin.resume();
2840
}
2941

3042
// @remove-on-eject-begin
@@ -44,8 +56,3 @@ argv.push(
4456
);
4557
// @remove-on-eject-end
4658
jest.run(argv);
47-
48-
process.stdin.on('end', function() {
49-
process.exit(0);
50-
});
51-
process.stdin.resume();

0 commit comments

Comments
 (0)