ctxloop 0.3.0 → 0.3.1
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/bin/graphsnip.js +15 -23
- package/package.json +1 -1
package/bin/graphsnip.js
CHANGED
|
@@ -1,29 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Thin launcher: graphsnip is a Python package. Try uvx, then pipx, then an installed python module.
|
|
3
|
-
// (It deliberately never calls a bare `graphsnip`, which would resolve back to this script.)
|
|
4
2
|
const { spawnSync } = require("child_process");
|
|
5
|
-
|
|
3
|
+
const version = require("../package.json").version;
|
|
4
|
+
const spec = "ctxloop==" + version;
|
|
6
5
|
const args = process.argv.slice(2);
|
|
7
|
-
const
|
|
8
|
-
["uvx", ["--from",
|
|
9
|
-
["pipx", ["run", "--spec",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
for (const [cmd, a] of attempts) {
|
|
15
|
-
const r = spawnSync(cmd, a, { stdio: "inherit" });
|
|
16
|
-
if (r.error && r.error.code === "ENOENT") continue; // tool not installed, try the next
|
|
17
|
-
if (cmd.startsWith("python") && r.status === 1 && r.signal == null) {
|
|
18
|
-
// `python -m graphsnip` exits 1 both for "module missing" and for real command errors; the former prints to stderr
|
|
19
|
-
// already via stdio inherit, so just pass the status through.
|
|
20
|
-
}
|
|
6
|
+
for (const [cmd, a] of [
|
|
7
|
+
["uvx", ["--from", spec, "ctxloop", ...args]],
|
|
8
|
+
["pipx", ["run", "--spec", spec, "ctxloop", ...args]],
|
|
9
|
+
]) {
|
|
10
|
+
const r = spawnSync(cmd, a, {stdio:"inherit"});
|
|
11
|
+
if (r.error && r.error.code === "ENOENT") continue;
|
|
21
12
|
process.exit(r.status === null ? 1 : r.status);
|
|
22
13
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
for (const cmd of ["python3", "python"]) {
|
|
15
|
+
const check = spawnSync(cmd, ["-c", "import importlib.metadata as m; print(m.version('ctxloop'))"], {encoding:"utf8"});
|
|
16
|
+
if (check.status !== 0 || check.stdout.trim() !== version) continue;
|
|
17
|
+
const r = spawnSync(cmd, ["-m", "ctxloop", ...args], {stdio:"inherit"});
|
|
18
|
+
process.exit(r.status === null ? 1 : r.status);
|
|
19
|
+
}
|
|
20
|
+
console.error("CtxLoop requires uv, pipx, or Python 3.10+ with " + spec + " installed.");
|
|
29
21
|
process.exit(127);
|