forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathvscEnvironmentShellDetector.ts
37 lines (34 loc) · 1.32 KB
/
vscEnvironmentShellDetector.ts
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { inject } from 'inversify';
import { Terminal } from 'vscode';
import { IApplicationEnvironment } from '../../application/types';
import { traceVerbose } from '../../logger';
import { ShellIdentificationTelemetry, TerminalShellType } from '../types';
import { BaseShellDetector } from './baseShellDetector';
/**
* Identifies the shell, based on the VSC Environment API.
*
* @export
* @class VSCEnvironmentShellDetector
* @extends {BaseShellDetector}
*/
export class VSCEnvironmentShellDetector extends BaseShellDetector {
constructor(@inject(IApplicationEnvironment) private readonly appEnv: IApplicationEnvironment) {
super(3);
}
public identify(
telemetryProperties: ShellIdentificationTelemetry,
_terminal?: Terminal,
): TerminalShellType | undefined {
if (!this.appEnv.shell) {
return;
}
const shell = this.identifyShellFromShellPath(this.appEnv.shell);
traceVerbose(`Terminal shell path '${this.appEnv.shell}' identified as shell '${shell}'`);
telemetryProperties.shellIdentificationSource =
shell === TerminalShellType.other ? telemetryProperties.shellIdentificationSource : 'vscode';
return shell;
}
}