mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
git extension: expose exec/spawn
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+18
-1
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user