forked from wakatime/vscode-wakatime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
desktop.ts
executable file
·31 lines (27 loc) · 881 Bytes
/
desktop.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
import * as fs from 'fs';
import * as os from 'os';
export class Desktop {
public static isWindows(): boolean {
return os.platform() === 'win32';
}
public static isPortable(): boolean {
return !!process.env['VSCODE_PORTABLE'];
}
public static getHomeDirectory(): string {
let home = process.env.WAKATIME_HOME;
if (home && home.trim() && fs.existsSync(home.trim()))
return home.trim();
if (this.isPortable())
return process.env['VSCODE_PORTABLE'] as string;
return process.env[this.isWindows() ? 'USERPROFILE' : 'HOME'] || process.cwd();
}
public static buildOptions(): Object {
const options = {
windowsHide: true,
};
if (!this.isWindows() && !process.env.WAKATIME_HOME && !process.env.HOME) {
options['env'] = { ...process.env, WAKATIME_HOME: this.getHomeDirectory() };
}
return options;
}
}