You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

42 rivejä
1.1 KiB

'use strict';
import { Disposable, Terminal, window } from 'vscode';
import { extensionTerminalName } from './constants';
import { Container } from './container';
let _terminal: Terminal | undefined;
let _terminalCwd: string | undefined;
let _disposable: Disposable | undefined;
function ensureTerminal(cwd: string): Terminal {
if (_terminal === undefined) {
_terminal = window.createTerminal(extensionTerminalName);
_disposable = window.onDidCloseTerminal((e: Terminal) => {
if (e.name === extensionTerminalName) {
_terminal = undefined;
_disposable!.dispose();
_disposable = undefined;
}
});
Container.context.subscriptions.push(_disposable);
_terminalCwd = undefined;
}
if (_terminalCwd !== cwd) {
_terminal.sendText(`cd "${cwd}"`, true);
_terminalCwd = cwd;
}
return _terminal;
}
export function runGitCommandInTerminal(command: string, args: string, cwd: string, execute: boolean = false) {
// let git = Git.getGitPath();
// if (git.includes(' ')) {
// git = `"${git}"`;
// }
const terminal = ensureTerminal(cwd);
terminal.show(false);
terminal.sendText(`git ${command} ${args}`, execute);
}