mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 12:33:35 +01:00
Merge branch 'master' into joh/ftp
This commit is contained in:
@@ -66,7 +66,7 @@ function findSpecificGit(path: string): Promise<IGit> {
|
||||
const buffers: Buffer[] = [];
|
||||
const child = cp.spawn(path, ['--version']);
|
||||
child.stdout.on('data', (b: Buffer) => buffers.push(b));
|
||||
child.on('error', e);
|
||||
child.on('error', cpErrorHandler(e));
|
||||
child.on('exit', code => code ? e(new Error('Not found')) : c({ path, version: parseVersion(Buffer.concat(buffers).toString('utf8').trim()) }));
|
||||
});
|
||||
}
|
||||
@@ -159,6 +159,20 @@ export interface IExecutionResult {
|
||||
stderr: string;
|
||||
}
|
||||
|
||||
function cpErrorHandler(cb: (reason?: any) => void): (reason?: any) => void {
|
||||
return err => {
|
||||
if (/ENOENT/.test(err.message)) {
|
||||
err = new GitError({
|
||||
error: err,
|
||||
message: 'Failed to execute git (ENOENT)',
|
||||
gitErrorCode: GitErrorCodes.NotAGitRepository
|
||||
});
|
||||
}
|
||||
|
||||
cb(err);
|
||||
};
|
||||
}
|
||||
|
||||
async function exec(child: cp.ChildProcess, options: any = {}): Promise<IExecutionResult> {
|
||||
if (!child.stdout || !child.stderr) {
|
||||
throw new GitError({
|
||||
@@ -183,7 +197,7 @@ async function exec(child: cp.ChildProcess, options: any = {}): Promise<IExecuti
|
||||
|
||||
const [exitCode, stdout, stderr] = await Promise.all<any>([
|
||||
new Promise<number>((c, e) => {
|
||||
once(child, 'error', e);
|
||||
once(child, 'error', cpErrorHandler(e));
|
||||
once(child, 'exit', c);
|
||||
}),
|
||||
new Promise<string>(c => {
|
||||
@@ -919,7 +933,7 @@ export class Repository {
|
||||
child.stderr.setEncoding('utf8');
|
||||
child.stderr.on('data', raw => stderrData.push(raw as string));
|
||||
|
||||
child.on('error', e);
|
||||
child.on('error', cpErrorHandler(e));
|
||||
child.on('exit', onExit);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user