Skip to content

Commit 62f671d

Browse files
chinesedfanKent C. Dodds
authored andcommitted
fix: output error messages if git commands failed (#102)
1 parent 2a98af3 commit 62f671d

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎src/util/git.js‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,16 @@ function getRepoInfo() {
3737

3838
const spawnGitCommand = pify((args, cb) => {
3939
const git = spawn('git', args)
40-
git.stderr.on('data', cb)
41-
git.on('close', cb)
40+
const bufs = [];
41+
git.stderr.on('data', (buf) => bufs.push(buf));
42+
git.on('close', (code) => {
43+
if (code) {
44+
const msg = Buffer.concat(bufs).toString() || `git ${args.join('')} - exit code: ${code}`;
45+
cb(new Error(msg));
46+
} else {
47+
cb(null);
48+
}
49+
});
4250
})
4351

4452
function commit(options, data) {

0 commit comments

Comments
 (0)