@oclif/core 4.11.4 → 4.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config/config.d.ts +0 -1
- package/lib/config/config.js +1 -24
- package/lib/util/os.d.ts +1 -0
- package/lib/util/os.js +28 -0
- package/package.json +1 -1
package/lib/config/config.d.ts
CHANGED
|
@@ -50,7 +50,6 @@ export declare class Config implements IConfig {
|
|
|
50
50
|
static get rootPlugin(): IPlugin | undefined;
|
|
51
51
|
get topics(): Topic[];
|
|
52
52
|
get versionDetails(): VersionDetails;
|
|
53
|
-
protected _shell(): string;
|
|
54
53
|
protected dir(category: 'cache' | 'config' | 'data'): string;
|
|
55
54
|
findCommand(id: string, opts: {
|
|
56
55
|
must: true;
|
package/lib/config/config.js
CHANGED
|
@@ -195,29 +195,6 @@ class Config {
|
|
|
195
195
|
shell: this.shell,
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
|
-
_shell() {
|
|
199
|
-
let shellPath;
|
|
200
|
-
const { COMSPEC } = process.env;
|
|
201
|
-
const SHELL = process.env.SHELL ?? (0, node_os_1.userInfo)().shell?.split(node_path_1.sep)?.pop();
|
|
202
|
-
if (SHELL) {
|
|
203
|
-
shellPath = SHELL.split('/');
|
|
204
|
-
}
|
|
205
|
-
else if (this.windows &&
|
|
206
|
-
(process.title.toLowerCase().includes('powershell') || process.title.toLowerCase().includes('pwsh'))) {
|
|
207
|
-
shellPath = ['powershell'];
|
|
208
|
-
}
|
|
209
|
-
else if (this.windows &&
|
|
210
|
-
(process.title.toLowerCase().includes('command prompt') || process.title.toLowerCase().includes('cmd'))) {
|
|
211
|
-
shellPath = ['cmd.exe'];
|
|
212
|
-
}
|
|
213
|
-
else if (this.windows && COMSPEC) {
|
|
214
|
-
shellPath = COMSPEC.split(/\\|\//);
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
shellPath = ['unknown'];
|
|
218
|
-
}
|
|
219
|
-
return shellPath.at(-1) ?? 'unknown';
|
|
220
|
-
}
|
|
221
198
|
dir(category) {
|
|
222
199
|
const base = process.env[`XDG_${category.toUpperCase()}_HOME`] ||
|
|
223
200
|
(this.windows && process.env.LOCALAPPDATA) ||
|
|
@@ -327,7 +304,7 @@ class Config {
|
|
|
327
304
|
if (this.platform === 'win32')
|
|
328
305
|
this.dirname = this.dirname.replace('/', '\\');
|
|
329
306
|
this.userAgent = `${this.name}/${this.version} ${this.platform}-${this.arch} node-${process.version}`;
|
|
330
|
-
this.shell =
|
|
307
|
+
this.shell = (0, os_1.getShell)();
|
|
331
308
|
this.home = process.env.HOME || (this.windows && this.windowsHome()) || (0, os_1.getHomeDir)() || (0, node_os_1.tmpdir)();
|
|
332
309
|
this.cacheDir = this.scopedEnvVar('CACHE_DIR') || this.macosCacheDir() || this.dir('cache');
|
|
333
310
|
this.configDir = this.scopedEnvVar('CONFIG_DIR') || this.dir('config');
|
package/lib/util/os.d.ts
CHANGED
package/lib/util/os.js
CHANGED
|
@@ -5,8 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getHomeDir = getHomeDir;
|
|
7
7
|
exports.getPlatform = getPlatform;
|
|
8
|
+
exports.getShell = getShell;
|
|
8
9
|
const is_wsl_1 = __importDefault(require("is-wsl"));
|
|
10
|
+
const node_child_process_1 = require("node:child_process");
|
|
9
11
|
const node_os_1 = require("node:os");
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
13
|
/**
|
|
11
14
|
* Call os.homedir() and return the result
|
|
12
15
|
*
|
|
@@ -29,3 +32,28 @@ function getHomeDir() {
|
|
|
29
32
|
function getPlatform() {
|
|
30
33
|
return is_wsl_1.default ? 'wsl' : (0, node_os_1.platform)();
|
|
31
34
|
}
|
|
35
|
+
function getShell() {
|
|
36
|
+
let shellPath;
|
|
37
|
+
const SHELL = process.env.SHELL ?? (0, node_os_1.userInfo)().shell?.split(node_path_1.default.sep)?.pop();
|
|
38
|
+
if (SHELL) {
|
|
39
|
+
shellPath = SHELL.split('/');
|
|
40
|
+
}
|
|
41
|
+
else if (getPlatform() === 'win32') {
|
|
42
|
+
shellPath = determineWindowsShell().split(node_path_1.default.sep);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
shellPath = ['unknown'];
|
|
46
|
+
}
|
|
47
|
+
return shellPath.at(-1) ?? 'unknown';
|
|
48
|
+
}
|
|
49
|
+
function determineWindowsShell() {
|
|
50
|
+
try {
|
|
51
|
+
const parentProcessName = (0, node_child_process_1.execSync)(`powershell.exe -NoProfile -Command "(Get-CimInstance Win32_Process -Filter 'ProcessID = ${process.ppid}').Name"`, { encoding: 'utf8' });
|
|
52
|
+
return parentProcessName.includes('powershell') || parentProcessName.includes('pwsh')
|
|
53
|
+
? 'powershell'
|
|
54
|
+
: (process.env.COMSPEC ?? 'cmd.exe');
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return process.env.COMSPEC ?? 'cmd.exe';
|
|
58
|
+
}
|
|
59
|
+
}
|