-
-
Notifications
You must be signed in to change notification settings - Fork 211
/
Copy pathterminal.js
42 lines (37 loc) · 973 Bytes
/
terminal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* Copyright (c) 2017-present PlatformIO <contact@platformio.org>
* All rights reserved.
*
* This source code is licensed under the license found in the LICENSE file in
* the root directory of this source tree.
*/
import vscode from 'vscode';
export default class PIOTerminal {
constructor() {
this._instance = undefined;
}
new() {
const envClone = Object.assign({}, process.env);
if (process.env.PLATFORMIO_PATH) {
envClone.PATH = process.env.PLATFORMIO_PATH;
envClone.Path = process.env.PLATFORMIO_PATH;
}
return vscode.window.createTerminal({
name: 'PlatformIO CLI',
env: envClone,
});
}
sendText(text) {
if (!this._instance || this._instance.exitStatus !== undefined) {
this._instance = this.new();
}
this._instance.sendText(text);
this._instance.show();
}
dispose() {
if (this._instance) {
this._instance.dispose();
}
this._instance = undefined;
}
}