aem-ext-daemon 0.3.2 → 0.3.4

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.
@@ -5,8 +5,36 @@
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
+ HOME: home,
35
+ PATH: `${extraPaths.join(":")}:${currentPath}`,
36
+ };
37
+ }
10
38
  /** Run a shell command synchronously and return stdout. */
11
39
  export function exec(command, cwd) {
12
40
  if (!command)
@@ -16,7 +44,8 @@ export function exec(command, cwd) {
16
44
  timeout: EXEC_TIMEOUT,
17
45
  maxBuffer: MAX_BUFFER,
18
46
  encoding: "utf-8",
19
- shell: "/bin/sh",
47
+ shell: getUserShell(),
48
+ env: getEnhancedEnv(),
20
49
  });
21
50
  return result;
22
51
  }
@@ -26,7 +55,8 @@ export function checkAio() {
26
55
  const version = execSync("aio --version", {
27
56
  timeout: 10_000,
28
57
  encoding: "utf-8",
29
- shell: "/bin/sh",
58
+ shell: getUserShell(),
59
+ env: getEnhancedEnv(),
30
60
  }).trim();
31
61
  return JSON.stringify({ installed: true, version });
32
62
  }
@@ -46,8 +76,8 @@ export function runAio(args, cwd, requestId, connection) {
46
76
  return new Promise((resolve, reject) => {
47
77
  const child = spawn("aio", args, {
48
78
  cwd,
49
- shell: true,
50
- env: { ...process.env },
79
+ shell: getUserShell(),
80
+ env: getEnhancedEnv(),
51
81
  });
52
82
  let stdout = "";
53
83
  let stderr = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aem-ext-daemon",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Local daemon for AEM Extension Builder — connects your machine to the cloud UI",
5
5
  "type": "module",
6
6
  "bin": {