viberoom 0.5.6 → 0.5.7
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/recipes.js +19 -2
- package/package.json +1 -1
package/dist/recipes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// viberoom - Copyright (c) 2026 Todor Rusev - AGPL-3.0-or-later; see LICENSE
|
|
2
2
|
import { execSync } from "node:child_process";
|
|
3
|
-
import { existsSync, readdirSync } from "node:fs";
|
|
3
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import { dirname, join } from "node:path";
|
|
@@ -110,6 +110,23 @@ function resolveGlobalNpmBin(name) {
|
|
|
110
110
|
const candidates = isWindows ? [join(root, "..", `${name}.cmd`)] : [join(root, "..", "..", "bin", name)];
|
|
111
111
|
return candidates.find((c) => existsSync(c)) ?? null;
|
|
112
112
|
}
|
|
113
|
+
function resolveGlobalPackageBin(packageName, command) {
|
|
114
|
+
const root = resolveGlobalNpmRoot();
|
|
115
|
+
if (!root)
|
|
116
|
+
return null;
|
|
117
|
+
const dir = join(root, packageName);
|
|
118
|
+
try {
|
|
119
|
+
const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
|
|
120
|
+
const entry = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.[command];
|
|
121
|
+
if (!entry)
|
|
122
|
+
return null;
|
|
123
|
+
const file = join(dir, entry);
|
|
124
|
+
return existsSync(file) ? file : null;
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
113
130
|
function resolveClaudeCode() {
|
|
114
131
|
const onPath = resolveOnPath(["claude"]);
|
|
115
132
|
if (onPath && !/\.(cmd|bat)$/i.test(onPath))
|
|
@@ -117,7 +134,7 @@ function resolveClaudeCode() {
|
|
|
117
134
|
const native = join(homedir(), ".local", "bin", isWindows ? "claude.exe" : "claude");
|
|
118
135
|
if (existsSync(native))
|
|
119
136
|
return native;
|
|
120
|
-
return
|
|
137
|
+
return resolveGlobalPackageBin("@anthropic-ai/claude-code", "claude");
|
|
121
138
|
}
|
|
122
139
|
function resolveCodex() {
|
|
123
140
|
return resolveGlobalNpmBin("codex") ?? resolveOnPath(["codex"]);
|