aem-ext-daemon 0.3.2 → 0.3.3
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/dist/capabilities/shell.js +33 -4
- package/package.json +1 -1
|
@@ -5,8 +5,35 @@
|
|
|
5
5
|
* shell:exec runs a command and returns the full output.
|
|
6
6
|
*/
|
|
7
7
|
import { execSync, spawn } from "node:child_process";
|
|
8
|
+
import os from "node:os";
|
|
8
9
|
const EXEC_TIMEOUT = 120_000; // 2 minutes
|
|
9
10
|
const MAX_BUFFER = 5 * 1024 * 1024; // 5MB
|
|
11
|
+
/** Resolve the user's login shell (falls back to /bin/sh). */
|
|
12
|
+
function getUserShell() {
|
|
13
|
+
return process.env.SHELL || "/bin/sh";
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Build a PATH that includes common tool locations.
|
|
17
|
+
* npx runs with a minimal env, so tools like git from Homebrew
|
|
18
|
+
* or nvm-managed node may not be on the default PATH.
|
|
19
|
+
*/
|
|
20
|
+
function getEnhancedEnv() {
|
|
21
|
+
const home = os.homedir();
|
|
22
|
+
const extraPaths = [
|
|
23
|
+
"/usr/local/bin",
|
|
24
|
+
"/opt/homebrew/bin",
|
|
25
|
+
"/opt/homebrew/sbin",
|
|
26
|
+
`${home}/.nvm/current/bin`,
|
|
27
|
+
`${home}/.volta/bin`,
|
|
28
|
+
`${home}/.cargo/bin`,
|
|
29
|
+
"/usr/local/git/bin",
|
|
30
|
+
];
|
|
31
|
+
const currentPath = process.env.PATH || "/usr/bin:/bin";
|
|
32
|
+
return {
|
|
33
|
+
...process.env,
|
|
34
|
+
PATH: `${extraPaths.join(":")}:${currentPath}`,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
10
37
|
/** Run a shell command synchronously and return stdout. */
|
|
11
38
|
export function exec(command, cwd) {
|
|
12
39
|
if (!command)
|
|
@@ -16,7 +43,8 @@ export function exec(command, cwd) {
|
|
|
16
43
|
timeout: EXEC_TIMEOUT,
|
|
17
44
|
maxBuffer: MAX_BUFFER,
|
|
18
45
|
encoding: "utf-8",
|
|
19
|
-
shell:
|
|
46
|
+
shell: getUserShell(),
|
|
47
|
+
env: getEnhancedEnv(),
|
|
20
48
|
});
|
|
21
49
|
return result;
|
|
22
50
|
}
|
|
@@ -26,7 +54,8 @@ export function checkAio() {
|
|
|
26
54
|
const version = execSync("aio --version", {
|
|
27
55
|
timeout: 10_000,
|
|
28
56
|
encoding: "utf-8",
|
|
29
|
-
shell:
|
|
57
|
+
shell: getUserShell(),
|
|
58
|
+
env: getEnhancedEnv(),
|
|
30
59
|
}).trim();
|
|
31
60
|
return JSON.stringify({ installed: true, version });
|
|
32
61
|
}
|
|
@@ -46,8 +75,8 @@ export function runAio(args, cwd, requestId, connection) {
|
|
|
46
75
|
return new Promise((resolve, reject) => {
|
|
47
76
|
const child = spawn("aio", args, {
|
|
48
77
|
cwd,
|
|
49
|
-
shell:
|
|
50
|
-
env:
|
|
78
|
+
shell: getUserShell(),
|
|
79
|
+
env: getEnhancedEnv(),
|
|
51
80
|
});
|
|
52
81
|
let stdout = "";
|
|
53
82
|
let stderr = "";
|