Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ function findChangedFiles(cwd) {

function isGitRepository(cwd) {
return new Promise(resolve => {
let stdout = '';
const options = ['rev-parse', '--show-toplevel'];
const child = childProcess.spawn('git', options, {cwd});
child.stdout.on('data', data => stdout += data);
child.on('error', () => resolve(null));
child.on('close', code => resolve(code === 0 ? stdout.trim() : null));
try {
let stdout = '';
const options = ['rev-parse', '--show-toplevel'];
const child = childProcess.spawn('git', options, {cwd});
child.stdout.on('data', data => stdout += data);
child.on('error', () => resolve(null));
child.on('close', code => resolve(code === 0 ? stdout.trim() : null));
} catch (e) {
resolve(null);
}
});
}

Expand Down
14 changes: 9 additions & 5 deletions src/lib/hg.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ function findChangedFiles(cwd) {

function isHGRepository(cwd) {
return new Promise(resolve => {
let stdout = '';
const child = childProcess.spawn('hg', ['root'], {cwd});
child.stdout.on('data', data => stdout += data);
child.on('error', () => resolve(null));
child.on('close', code => resolve(code === 0 ? stdout.trim() : null));
try {
let stdout = '';
const child = childProcess.spawn('hg', ['root'], {cwd});
child.stdout.on('data', data => stdout += data);
child.on('error', () => resolve(null));
child.on('close', code => resolve(code === 0 ? stdout.trim() : null));
} catch (e) {
resolve(null);
}
});
}

Expand Down