Skip to content

Commit b9a5862

Browse files
mateusz-facebook-github-bot
authored andcommitted
react-native-git-upgrade signal termination
Summary: When performing an upgrade using react-native-git-upgrade git can fail with a signal, however, only exit codes are accounted for. Related issue: #12336 In my case, Git fails with a `SIGPIPE` signal - have not figured out why yet, but that's a separate issue. Before, since exit code was not zero, the console would default to the error case, but since no exit code was supplied, the error message was meaningless - `exited with code null`. Now, it errors out with `terminated with signal 'SIGPIPE'`, while still taking account of exit codes. Quoting [nodejs docs](https://nodejs.org/api/child_process.html#child_process_event_exit): > The 'exit' event is emitted after the child process ends. If the process exited, code is the final exit code of the process, otherwise null. If the process terminated due to receipt of a signal, signal is the string name of the signal, otherwise null. One of the two will always be non-null. I would be happy to write a test case for this but I haven't seen any react-native-git-upgrade ones? [CLI] [ENHANCEMENT] [react-native/react-native-git-upgrade] - Git terminated by signal error message Closes #16822 Differential Revision: D6387451 Pulled By: shergin fbshipit-source-id: 25bf9dabdb5fda70d220bcd5f14c3c92bba8c3d4
1 parent 15179f1 commit b9a5862

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

react-native-git-upgrade/cliEntry.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,18 @@ function exec(command, logOutput) {
5252
process.stderr.write(data);
5353
});
5454

55-
child.on('exit', code => {
56-
(code === 0)
57-
? resolve(stdout)
58-
: reject(new Error(`Command '${command}' exited with code ${code}:
55+
child.on('exit', (code, signal) => {
56+
if (code === 0) {
57+
resolve(stdout);
58+
} else if (code) {
59+
reject(new Error(`Command '${command}' exited with code ${code}:
5960
stderr: ${stderr}
6061
stdout: ${stdout}`));
62+
} else {
63+
reject(new Error(`Command '${command}' terminated with signal '${signal}':
64+
stderr: ${stderr}
65+
stdout: ${stdout}`));
66+
}
6167
});
6268
});
6369
}

0 commit comments

Comments
 (0)