git extension: expose exec/spawn

This commit is contained in:
Joao Moreno
2018-08-22 12:31:46 +02:00
parent 1341461209
commit 8983d89550
2 changed files with 28 additions and 1 deletions
+10
View File
@@ -11,6 +11,7 @@ import { Api } from './api';
import { Event, SourceControlInputBox, Uri } from 'vscode';
import { mapEvent } from '../util';
import { Repository } from '../repository';
import * as cp from 'child_process';
class ApiInputBox implements GitExtension.InputBox {
set value(value: string) { this._inputBox.value = value; }
@@ -49,4 +50,13 @@ export class ApiImpl implements GitExtension.API {
}
constructor(private _model: Model) { }
exec(cwd: string, args: string[], options: GitExtension.SpawnOptions = {}): Promise<GitExtension.IExecResult<string>> {
return this._model.git.exec(cwd, args, options);
}
spawn(cwd: string, args: string[], options: GitExtension.SpawnOptions = {}): cp.ChildProcess {
options = { cwd, ...options };
return this._model.git.spawn(args, options);
}
}
+18 -1
View File
@@ -3,15 +3,32 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Uri, SourceControlInputBox, Event } from 'vscode';
import { Uri, SourceControlInputBox, Event, CancellationToken } from 'vscode';
import * as cp from 'child_process';
declare module GitExtension {
export interface IExecResult<T extends string | Buffer> {
readonly exitCode: number;
readonly stdout: T;
readonly stderr: string;
}
export interface SpawnOptions extends cp.SpawnOptions {
readonly input?: string;
readonly encoding?: string;
readonly log?: boolean;
readonly cancellationToken?: CancellationToken;
}
export interface API {
readonly gitPath: string;
readonly repositories: Repository[];
readonly onDidOpenRepository: Event<Repository>;
readonly onDidCloseRepository: Event<Repository>;
exec(cwd: string, args: string[], options?: SpawnOptions): Promise<IExecResult<string>>;
spawn(cwd: string, args: string[], options?: SpawnOptions): cp.ChildProcess;
}
export interface InputBox {