docs-i18n 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/dist/cli.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "./chunk-SKKZIV3L.js";
|
|
11
11
|
|
|
12
12
|
// src/admin/server/index.ts
|
|
13
|
+
import { spawn as nodeSpawn } from "child_process";
|
|
13
14
|
import { createServer } from "http";
|
|
14
15
|
import { resolve as resolve2 } from "path";
|
|
15
16
|
import { Hono as Hono4 } from "hono";
|
|
@@ -488,15 +489,18 @@ async function startAdmin(config, port = 3456) {
|
|
|
488
489
|
if (!fullPath.startsWith(process.cwd())) return c.json({ error: "Invalid path" }, 400);
|
|
489
490
|
const candidates = process.env.EDITOR_CMD ? [process.env.EDITOR_CMD] : ["code", "cursor", "zed"];
|
|
490
491
|
for (const cmd of candidates) {
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
492
|
+
const found = await new Promise((r) => {
|
|
493
|
+
const p = nodeSpawn("which", [cmd], { stdio: "ignore" });
|
|
494
|
+
p.on("exit", (code) => r(code === 0));
|
|
495
|
+
p.on("error", () => r(false));
|
|
496
|
+
});
|
|
497
|
+
if (found) {
|
|
498
|
+
nodeSpawn(cmd, [fullPath], { stdio: "ignore", detached: true }).unref();
|
|
495
499
|
return c.json({ opened: fullPath, editor: cmd });
|
|
496
500
|
}
|
|
497
501
|
}
|
|
498
502
|
const fallback = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
499
|
-
|
|
503
|
+
nodeSpawn(fallback, [fullPath], { stdio: "ignore", detached: true }).unref();
|
|
500
504
|
return c.json({ opened: fullPath, editor: fallback });
|
|
501
505
|
});
|
|
502
506
|
const thisFile = new URL(import.meta.url).pathname;
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { spawn as nodeSpawn } from 'node:child_process';
|
|
1
2
|
import { createServer } from 'node:http';
|
|
2
3
|
import { resolve } from 'node:path';
|
|
3
4
|
import { Hono } from 'hono';
|
|
@@ -26,15 +27,18 @@ export async function startAdmin(config: DocsI18nConfig, port = 3456) {
|
|
|
26
27
|
|
|
27
28
|
const candidates = process.env.EDITOR_CMD ? [process.env.EDITOR_CMD] : ['code', 'cursor', 'zed'];
|
|
28
29
|
for (const cmd of candidates) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const found = await new Promise<boolean>((r) => {
|
|
31
|
+
const p = nodeSpawn('which', [cmd], { stdio: 'ignore' });
|
|
32
|
+
p.on('exit', (code) => r(code === 0));
|
|
33
|
+
p.on('error', () => r(false));
|
|
34
|
+
});
|
|
35
|
+
if (found) {
|
|
36
|
+
nodeSpawn(cmd, [fullPath], { stdio: 'ignore', detached: true }).unref();
|
|
33
37
|
return c.json({ opened: fullPath, editor: cmd });
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
const fallback = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
|
|
37
|
-
|
|
41
|
+
nodeSpawn(fallback, [fullPath], { stdio: 'ignore', detached: true }).unref();
|
|
38
42
|
return c.json({ opened: fullPath, editor: fallback });
|
|
39
43
|
});
|
|
40
44
|
|