@songsid/agend 2.2.0-beta.12 → 2.2.0-beta.13

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
@@ -2630,6 +2630,16 @@ program
2630
2630
  const { runSetupWizard } = await import("./setup-wizard.js");
2631
2631
  await runSetupWizard();
2632
2632
  });
2633
+ // The opener is optional (a server or WSL without xdg-open): a spawn failure is an `error` event, and unhandled it
2634
+ // crashed the command after the link was already printed (#1854). The printed link still works, so say so instead.
2635
+ function openInBrowser(url) {
2636
+ const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "explorer" : "xdg-open";
2637
+ const child = spawn(cmd, [url], { detached: true, stdio: "ignore" });
2638
+ child.on("error", (err) => {
2639
+ console.error(`Could not open a browser (${cmd}: ${err.code ?? err.message}). Open the link above yourself.`);
2640
+ });
2641
+ child.unref();
2642
+ }
2633
2643
  program
2634
2644
  .command("web")
2635
2645
  .description("Open the Web UI sign-in page in your browser and print a one-time sign-in code")
@@ -2672,9 +2682,7 @@ program
2672
2682
  console.log(`Code: ${code} (works once, valid ~${minutes} min)`);
2673
2683
  if (opts.code)
2674
2684
  return;
2675
- const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "explorer" : "xdg-open";
2676
- const child = spawn(cmd, [signin], { detached: true, stdio: "ignore" });
2677
- child.unref();
2685
+ openInBrowser(signin);
2678
2686
  });
2679
2687
  program
2680
2688
  .command("web-token")
@@ -2704,9 +2712,7 @@ program
2704
2712
  const port = fleet.health_port ?? 19280;
2705
2713
  const url = `http://localhost:${port}/view`;
2706
2714
  console.log(`Opening ${url}`);
2707
- const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "explorer" : "xdg-open";
2708
- const child = spawn(cmd, [url], { detached: true, stdio: "ignore" });
2709
- child.unref();
2715
+ openInBrowser(url);
2710
2716
  });
2711
2717
  program
2712
2718
  .command("validate")