docs-i18n 0.3.0 → 0.3.2

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
@@ -88,7 +88,7 @@ Options:
88
88
  }
89
89
  case "admin": {
90
90
  const port = Number(getOpt("port", "3456"));
91
- const { startAdmin } = await import("./server-XRHMURM5.js");
91
+ const { startAdmin } = await import("./server-2FW3TPYF.js");
92
92
  await startAdmin(config, port);
93
93
  break;
94
94
  }
@@ -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 which = Bun.spawn(["which", cmd], { stdio: ["ignore", "pipe", "ignore"] });
492
- await which.exited;
493
- if (which.exitCode === 0) {
494
- Bun.spawn([cmd, fullPath], { stdio: ["ignore", "ignore", "ignore"] });
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
- Bun.spawn([fallback, fullPath], { stdio: ["ignore", "ignore", "ignore"] });
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,6 +1,6 @@
1
1
  {
2
2
  "name": "docs-i18n",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Universal documentation translation engine — parse, translate, cache, assemble, manage.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -24,7 +24,7 @@
24
24
  "typecheck": "tsc --noEmit",
25
25
  "lint": "biome check .",
26
26
  "lint:fix": "biome check --write .",
27
- "prepublishOnly": "tsup && chmod +x dist/cli.js"
27
+ "prepublishOnly": "rm -rf dist && tsup && chmod +x dist/cli.js"
28
28
  },
29
29
  "dependencies": {
30
30
  "better-sqlite3": "^12.8.0",
@@ -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 which = Bun.spawn(['which', cmd], { stdio: ['ignore', 'pipe', 'ignore'] });
30
- await which.exited;
31
- if (which.exitCode === 0) {
32
- Bun.spawn([cmd, fullPath], { stdio: ['ignore', 'ignore', 'ignore'] });
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
- Bun.spawn([fallback, fullPath], { stdio: ['ignore', 'ignore', 'ignore'] });
41
+ nodeSpawn(fallback, [fullPath], { stdio: 'ignore', detached: true }).unref();
38
42
  return c.json({ opened: fullPath, editor: fallback });
39
43
  });
40
44