@dsdenes/devboard 0.1.151 → 0.1.152

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.
Files changed (2) hide show
  1. package/bin/devboard.mjs +17 -3
  2. package/package.json +1 -1
package/bin/devboard.mjs CHANGED
@@ -32,6 +32,7 @@ import {
32
32
  writeFile,
33
33
  } from "node:fs/promises";
34
34
  import { createServer } from "node:net";
35
+ import { homedir } from "node:os";
35
36
  import { basename, dirname, join, resolve, sep } from "node:path";
36
37
  import { fileURLToPath } from "node:url";
37
38
 
@@ -88,9 +89,19 @@ function firstLine(text) {
88
89
 
89
90
  class LauncherError extends Error {}
90
91
 
92
+ function safeCwd(cwd) {
93
+ if (cwd !== undefined) return cwd;
94
+ try {
95
+ const current = process.cwd();
96
+ return existsSync(current) ? current : homedir();
97
+ } catch {
98
+ return homedir();
99
+ }
100
+ }
101
+
91
102
  function run(command, args, options = {}) {
92
103
  const result = spawnSync(command, args, {
93
- cwd: options.cwd,
104
+ cwd: safeCwd(options.cwd),
94
105
  env: { ...process.env, ...options.env, GH_PROMPT_DISABLED: "1" },
95
106
  encoding: "utf8",
96
107
  timeout: options.timeoutMs ?? 120_000,
@@ -437,7 +448,7 @@ async function installTarball(prefix, tarball, version) {
437
448
  ["install", "--prefix", staging, "--ignore-scripts", "--no-audit", "--no-fund",
438
449
  "--no-save", tarball],
439
450
  "npm install",
440
- { timeoutMs: 10 * 60_000 },
451
+ { cwd: staging, timeoutMs: 10 * 60_000 },
441
452
  );
442
453
  const staged = harnessDir(staging);
443
454
  const stagedVersion = installedVersion(staging);
@@ -643,7 +654,10 @@ async function startDashboard(host, harness, port, stateDir) {
643
654
  await mkdir(stateDir, { recursive: true });
644
655
  const fd = openSync(log, "a");
645
656
  const child = spawn(bun, [join(harness, "server", "index.ts")], {
646
- cwd: harness,
657
+ // Keep the dashboard out of the replaceable package directory: an update
658
+ // renames and removes it, leaving a deleted cwd that child processes
659
+ // cannot start from.
660
+ cwd: host,
647
661
  detached: true,
648
662
  stdio: ["ignore", fd, fd],
649
663
  env: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsdenes/devboard",
3
- "version": "0.1.151",
3
+ "version": "0.1.152",
4
4
  "description": "Launcher for the private Devboard harness: install, update, and doctor.",
5
5
  "type": "module",
6
6
  "bin": {