Skip to content

Commit

Permalink
Review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan committed Aug 1, 2017
1 parent 201ea6b commit 9643175
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
process.kill(process.pid, "SIGSEGV");
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"scripts": {
"compile": "gcc segfault.c -g -o segfault",
"pretest": "yarn run compile",
"test": "./segfault",
"pretest-alt": "yarn run compile",
"test-alt": "./segfault && true"
"test": "node app.js"
}
}

This file was deleted.

2 changes: 1 addition & 1 deletion __tests__/lifecycle-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ test('should show correct error message when the script ends with an exit code',

test('should show correct error message when the script ends an exit signal', async () => {
await execCommand('test', 'script-segfault').catch(error => {
expect(error.message).toMatch(/Command failed with signal /);
expect(error.message).toMatch(/Command failed with signal "SIGSEGV"/);
expect(error.code).not.toBe(0);
});
});
16 changes: 2 additions & 14 deletions src/util/child.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,30 +95,18 @@ export function spawn(
}

proc.on('close', (code: number, signal: string) => {
if (signal) {
if (signal || code >= 1) {
err = new SpawnError(
[
'Command failed.',
`Exit signal: ${signal}`,
signal ? `Exit signal: ${signal}` : `Exit code: ${code}`,
`Command: ${program}`,
`Arguments: ${args.join(' ')}`,
`Directory: ${opts.cwd || process.cwd()}`,
`Output:\n${stdout.trim()}`,
].join('\n'),
);
err.EXIT_SIGNAL = signal;
} else if (code >= 1) {
// TODO make this output nicer
err = new SpawnError(
[
'Command failed.',
`Exit code: ${code}`,
`Command: ${program}`,
`Arguments: ${args.join(' ')}`,
`Directory: ${opts.cwd || process.cwd()}`,
`Output:\n${stdout.trim()}`,
].join('\n'),
);
err.EXIT_CODE = code;
}

Expand Down

0 comments on commit 9643175

Please sign in to comment.