Skip to content

Commit d28f017

Browse files
committed
handle exit code
1 parent 09e7cae commit d28f017

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/exec.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { info } from '@actions/core';
1+
import { info, debug, error, setFailed } from '@actions/core';
22
import proc from 'child_process';
3-
import { debug, error } from 'console';
43
import { Transform } from 'stream';
54
import which from 'which';
65

@@ -60,8 +59,12 @@ export const exec = (argv: string[]): Promise<string> => {
6059
reject(err);
6160
});
6261

63-
p.on('exit', () => {
64-
debug('Command exited');
62+
p.on('exit', (code) => {
63+
debug(`${command} exited with code ${code}`);
64+
if (code && code !== 0) {
65+
reject(new Error(`${command} exited with code ${code}`));
66+
return;
67+
}
6568
resolve(capture.toString());
6669
});
6770

0 commit comments

Comments
 (0)