forked from platformio/platformio-vscode-ide
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathterminal.js
More file actions
61 lines (54 loc) · 1.29 KB
/
terminal.js
File metadata and controls
61 lines (54 loc) · 1.29 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* 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 * as constants from './constants';
import vscode from 'vscode';
export default class PIOTerminal {
constructor() {
this._instance = undefined;
}
new() {
return vscode.window.createTerminal({
name: 'PlatformIO',
env: process.env
});
}
sendText(text) {
if (!this._instance) {
this._instance = this.new();
}
this._instance.sendText(text);
this._instance.show();
}
dispose() {
if (this._instance) {
this._instance.dispose();
}
this._instance = undefined;
}
updateEnvConfiguration() {
const config = vscode.workspace.getConfiguration();
const sysType = constants.IS_WINDOWS
? 'windows'
: constants.IS_OSX
? 'osx'
: 'linux';
const section = `terminal.integrated.env.${sysType}`;
const current = config.get(section);
if (current && current.PATH === process.env.PATH) {
return;
}
config.update(
section,
{
PATH: process.env.PATH,
PLATFORMIO_CALLER: 'vscode'
},
vscode.ConfigurationTarget.Workspace
);
}
}