@syengup/friday-channel-next 0.1.7 → 0.1.8

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.
@@ -1,29 +1,31 @@
1
- import { execSync } from "node:child_process";
2
- import { readdirSync, realpathSync } from "node:fs";
3
- import { dirname, join } from "node:path";
1
+ import { existsSync, readdirSync, realpathSync } from "node:fs";
2
+ import { delimiter, dirname, join } from "node:path";
4
3
  let cache = null;
5
- function resolveOpenClawDistFromBin() {
6
- try {
7
- const whichCmd = process.platform === "win32" ? "where" : "which";
8
- const raw = execSync(`${whichCmd} openclaw`, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
9
- const binPath = raw.split("\n")[0].trim();
10
- if (!binPath)
11
- return null;
12
- const real = realpathSync(binPath);
13
- const dist = join(dirname(real), "dist");
14
- readdirSync(dist); // throw if not a readable directory
15
- return dist;
16
- }
17
- catch {
18
- return null;
4
+ function resolveOpenClawDistFromPath() {
5
+ // Walk PATH looking for the openclaw binary, then resolve its real
6
+ // location to find the dist/ directory. No shell commands needed.
7
+ const binName = process.platform === "win32" ? "openclaw.cmd" : "openclaw";
8
+ const pathDirs = (process.env.PATH ?? "").split(delimiter);
9
+ for (const dir of pathDirs) {
10
+ const candidate = join(dir, binName);
11
+ if (!existsSync(candidate))
12
+ continue;
13
+ try {
14
+ const real = realpathSync(candidate);
15
+ const dist = join(dirname(real), "dist");
16
+ readdirSync(dist);
17
+ return dist;
18
+ }
19
+ catch { }
19
20
  }
21
+ return null;
20
22
  }
21
23
  function resolveOpenClawDist() {
22
24
  // Priority order:
23
25
  // 1. OPENCLAW_DIST env var (explicit override, works everywhere)
24
26
  // 2. Resolve the `openclaw` binary on PATH → dist/ (robust, cross-platform)
25
27
  // 3. Platform-specific standard install paths
26
- const fromBin = resolveOpenClawDistFromBin();
28
+ const fromBin = resolveOpenClawDistFromPath();
27
29
  const candidates = [
28
30
  process.env.OPENCLAW_DIST,
29
31
  fromBin,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syengup/friday-channel-next",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "OpenClaw Friday Next Apple channel plugin",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,22 +1,24 @@
1
- import { execSync } from "node:child_process";
2
- import { readdirSync, realpathSync } from "node:fs";
3
- import { dirname, join } from "node:path";
1
+ import { existsSync, readdirSync, realpathSync } from "node:fs";
2
+ import { delimiter, dirname, join } from "node:path";
4
3
 
5
4
  let cache: { listNodePairing: Function; approveNodePairing: Function } | null = null;
6
5
 
7
- function resolveOpenClawDistFromBin(): string | null {
8
- try {
9
- const whichCmd = process.platform === "win32" ? "where" : "which";
10
- const raw = execSync(`${whichCmd} openclaw`, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
11
- const binPath = raw.split("\n")[0].trim();
12
- if (!binPath) return null;
13
- const real = realpathSync(binPath);
14
- const dist = join(dirname(real), "dist");
15
- readdirSync(dist); // throw if not a readable directory
16
- return dist;
17
- } catch {
18
- return null;
6
+ function resolveOpenClawDistFromPath(): string | null {
7
+ // Walk PATH looking for the openclaw binary, then resolve its real
8
+ // location to find the dist/ directory. No shell commands needed.
9
+ const binName = process.platform === "win32" ? "openclaw.cmd" : "openclaw";
10
+ const pathDirs = (process.env.PATH ?? "").split(delimiter);
11
+ for (const dir of pathDirs) {
12
+ const candidate = join(dir, binName);
13
+ if (!existsSync(candidate)) continue;
14
+ try {
15
+ const real = realpathSync(candidate);
16
+ const dist = join(dirname(real), "dist");
17
+ readdirSync(dist);
18
+ return dist;
19
+ } catch {}
19
20
  }
21
+ return null;
20
22
  }
21
23
 
22
24
  function resolveOpenClawDist(): string {
@@ -24,7 +26,7 @@ function resolveOpenClawDist(): string {
24
26
  // 1. OPENCLAW_DIST env var (explicit override, works everywhere)
25
27
  // 2. Resolve the `openclaw` binary on PATH → dist/ (robust, cross-platform)
26
28
  // 3. Platform-specific standard install paths
27
- const fromBin = resolveOpenClawDistFromBin();
29
+ const fromBin = resolveOpenClawDistFromPath();
28
30
  const candidates: string[] = [
29
31
  process.env.OPENCLAW_DIST,
30
32
  fromBin,