提交 c96f5d12 编写于 作者: D Daniel Imms

Import and type windows-process-tree

Fixes #43287
上级 7d9ccca1
......@@ -9,6 +9,8 @@ declare module 'windows-process-tree' {
name: string,
children: ProcessTreeNode[]
}
function get(rootPid: number, callback: (tree: ProcessTreeNode) => void): void;
export = get;
}
......@@ -8,10 +8,11 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { Emitter, debounceEvent } from 'vs/base/common/event';
import { ITerminalInstance } from 'vs/workbench/parts/terminal/common/terminal';
import { Terminal as XTermTerminal } from 'vscode-xterm';
import WindowsProcessTreeType = require('windows-process-tree');
const SHELL_EXECUTABLES = ['cmd.exe', 'powershell.exe', 'bash.exe'];
let windowsProcessTree;
let windowsProcessTree: typeof WindowsProcessTreeType;
export class WindowsShellHelper {
private _onCheckShell: Emitter<TPromise<string>>;
......@@ -28,11 +29,14 @@ export class WindowsShellHelper {
throw new Error(`WindowsShellHelper cannot be instantiated on ${platform.platform}`);
}
if (!windowsProcessTree) {
windowsProcessTree = require.__$__nodeRequire('windows-process-tree');
this._isDisposed = false;
(import('windows-process-tree')).then(mod => {
if (this._isDisposed) {
return;
}
this._isDisposed = false;
windowsProcessTree = mod;
this._onCheckShell = new Emitter<TPromise<string>>();
// The debounce is necessary to prevent multiple processes from spawning when
// the enter key or output is spammed
......@@ -56,6 +60,7 @@ export class WindowsShellHelper {
// Fire a new check for the shell when any key is pressed.
this._xterm.on('keypress', () => this._onCheckShell.fire());
});
}
private checkShell(): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册