@fedify/init 2.2.0-dev.692 → 2.2.0-dev.695

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/deno.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region deno.json
2
- var version = "2.2.0-dev.692+12c62883";
2
+ var version = "2.2.0-dev.695+568b08cc";
3
3
  //#endregion
4
4
  export { version };
@@ -1,8 +1,10 @@
1
1
  import { printErrorMessage } from "../utils.js";
2
2
  import { ensurePortReleased, killProcessOnPort } from "./port.js";
3
- import $ from "@david/dax";
3
+ import process from "node:process";
4
4
  import { createWriteStream } from "node:fs";
5
5
  import { join } from "node:path";
6
+ import { spawn } from "node:child_process";
7
+ import { Readable } from "node:stream";
6
8
  //#region src/test/server.ts
7
9
  const STARTUP_TIMEOUT = 1e4;
8
10
  /**
@@ -23,10 +25,25 @@ async function waitForServer(url, timeout = STARTUP_TIMEOUT) {
23
25
  }
24
26
  async function serverClosure(dir, cmd, defaultPort, callback, releasePort) {
25
27
  await releasePort?.();
26
- const serverProcess = $`${cmd.split(" ")}`.cwd(dir).env("PORT", String(defaultPort)).stdin("null").stdout("piped").stderr("piped").noThrow().spawn();
27
- serverProcess.catch(() => {});
28
- const [stdoutForFile, stdoutForPort] = serverProcess.stdout().tee();
29
- const [stderrForFile, stderrForPort] = serverProcess.stderr().tee();
28
+ const devCommand = cmd.split(" ");
29
+ const child = spawn(devCommand[0], devCommand.slice(1), {
30
+ cwd: dir,
31
+ env: {
32
+ ...process.env,
33
+ PORT: String(defaultPort)
34
+ },
35
+ stdio: [
36
+ "ignore",
37
+ "pipe",
38
+ "pipe"
39
+ ],
40
+ detached: true
41
+ });
42
+ child.on("error", () => {});
43
+ const stdoutWeb = Readable.toWeb(child.stdout);
44
+ const stderrWeb = Readable.toWeb(child.stderr);
45
+ const [stdoutForFile, stdoutForPort] = stdoutWeb.tee();
46
+ const [stderrForFile, stderrForPort] = stderrWeb.tee();
30
47
  const cleanup = new AbortController();
31
48
  const outFile = createWriteStream(join(dir, "out.txt"), { flags: "a" });
32
49
  const errFile = createWriteStream(join(dir, "err.txt"), { flags: "a" });
@@ -42,7 +59,10 @@ async function serverClosure(dir, cmd, defaultPort, callback, releasePort) {
42
59
  return await callback(port);
43
60
  } finally {
44
61
  try {
45
- serverProcess.kill("SIGKILL");
62
+ if (child.pid != null) process.kill(-child.pid, "SIGKILL");
63
+ } catch {}
64
+ try {
65
+ child.kill("SIGKILL");
46
66
  } catch {}
47
67
  cleanup.abort();
48
68
  await Promise.all([pipeOutDone, pipeErrDone]).catch(() => {});
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { toMerged } from "es-toolkit";
2
2
  import { message } from "@optique/core";
3
+ import { spawn } from "node:child_process";
4
+
3
5
  //#region src/utils.d.ts
4
6
  /** Makes all properties of `T` required and non-nullable. */
5
7
  type RequiredNotNull<T> = { [P in keyof T]: NonNullable<T[P]> };
package/dist/utils.js CHANGED
@@ -4,6 +4,7 @@ import { print, printError } from "@optique/run";
4
4
  import { flow, toMerged } from "es-toolkit";
5
5
  import { message } from "@optique/core";
6
6
  import { Chalk } from "chalk";
7
+ import "node:child_process";
7
8
  /** Chalk instance configured based on {@link colorEnabled}. */
8
9
  const colors = new Chalk(process.stdout.isTTY && !("NO_COLOR" in process.env && process.env.NO_COLOR !== "") ? {} : { level: 0 });
9
10
  /** Type guard that checks whether a value is a `Promise`. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/init",
3
- "version": "2.2.0-dev.692+12c62883",
3
+ "version": "2.2.0-dev.695+568b08cc",
4
4
  "description": "Project initializer for Fedify",
5
5
  "keywords": [
6
6
  "fedify",