1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
18 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
19 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
20 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
21 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
22 | };
|
23 | var __metadata = (this && this.__metadata) || function (k, v) {
|
24 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
25 | };
|
26 | Object.defineProperty(exports, "__esModule", { value: true });
|
27 | exports.EnvVariablesServerImpl = void 0;
|
28 | const path_1 = require("path");
|
29 | const os_1 = require("os");
|
30 | const inversify_1 = require("inversify");
|
31 | const drivelist = require("drivelist");
|
32 | const os_2 = require("../../common/os");
|
33 | const file_uri_1 = require("../file-uri");
|
34 | let EnvVariablesServerImpl = class EnvVariablesServerImpl {
|
35 | constructor() {
|
36 | this.envs = {};
|
37 | this.homeDirUri = file_uri_1.FileUri.create((0, os_1.homedir)()).toString();
|
38 | this.configDirUri = this.createConfigDirUri();
|
39 | this.configDirUri.then(configDirUri => console.log(`Configuration directory URI: '${configDirUri}'`));
|
40 | const prEnv = process.env;
|
41 | Object.keys(prEnv).forEach((key) => {
|
42 | let keyName = key;
|
43 | if (os_2.isWindows) {
|
44 | keyName = key.toLowerCase();
|
45 | }
|
46 | this.envs[keyName] = { 'name': keyName, 'value': prEnv[key] };
|
47 | });
|
48 | }
|
49 | async createConfigDirUri() {
|
50 | return file_uri_1.FileUri.create(process.env.THEIA_CONFIG_DIR || (0, path_1.join)((0, os_1.homedir)(), '.theia')).toString();
|
51 | }
|
52 | async getExecPath() {
|
53 | return process.execPath;
|
54 | }
|
55 | async getVariables() {
|
56 | return Object.keys(this.envs).map(key => this.envs[key]);
|
57 | }
|
58 | async getValue(key) {
|
59 | if (os_2.isWindows) {
|
60 | key = key.toLowerCase();
|
61 | }
|
62 | return this.envs[key];
|
63 | }
|
64 | getConfigDirUri() {
|
65 | return this.configDirUri;
|
66 | }
|
67 | async getHomeDirUri() {
|
68 | return this.homeDirUri;
|
69 | }
|
70 | async getDrives() {
|
71 | const uris = [];
|
72 | const drives = await drivelist.list();
|
73 | for (const drive of drives) {
|
74 | for (const mountpoint of drive.mountpoints) {
|
75 | if (this.filterHiddenPartitions(mountpoint.path)) {
|
76 | uris.push(file_uri_1.FileUri.create(mountpoint.path).toString());
|
77 | }
|
78 | }
|
79 | }
|
80 | return uris;
|
81 | }
|
82 | |
83 |
|
84 |
|
85 | filterHiddenPartitions(path) {
|
86 |
|
87 | if (path === '/private/var/vm') {
|
88 | return false;
|
89 | }
|
90 |
|
91 | if (path === '/boot/efi') {
|
92 | return false;
|
93 | }
|
94 | return true;
|
95 | }
|
96 | };
|
97 | EnvVariablesServerImpl = __decorate([
|
98 | (0, inversify_1.injectable)(),
|
99 | __metadata("design:paramtypes", [])
|
100 | ], EnvVariablesServerImpl);
|
101 | exports.EnvVariablesServerImpl = EnvVariablesServerImpl;
|
102 |
|
\ | No newline at end of file |