Skip to content

Commit 23feac1

Browse files
committed
feat: log error messages produced by git
1 parent 8f6ee69 commit 23feac1

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/utils.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,17 @@ const executeCommand = async (
5252
const executeGitCommand = (cwd: string, args: string[] = []): Promise<void> =>
5353
new Promise(
5454
(resolve: () => void, reject: (reason?: string | Error) => void) => {
55-
const process = spawn('git', args, { cwd });
55+
const stderr = [];
56+
const process = spawn('git', args, { cwd, stdio: [0, 0, 'pipe'] });
5657

58+
process.stderr.setEncoding('utf-8');
59+
process.stderr.on('data', (chunk) => stderr.push(chunk));
5760
process.on('error', () => reject(`Error occurred during execution!`));
58-
process.on('close', (code: number) => {
59-
if (code !== 0) {
60-
reject(`Exited with code ${code}!`);
61-
} else {
62-
resolve();
63-
}
64-
});
61+
process.on('close', (code: number) =>
62+
code === 0
63+
? resolve()
64+
: reject(`Exited with code ${code}. Details:\n\n${stderr.join('')}`)
65+
);
6566
}
6667
);
6768

0 commit comments

Comments
 (0)