Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* npx devshelf open <name> # Open resource URL in default browser
*/

import { exec } from "node:child_process";
import { spawn } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import readline from "node:readline";
Expand Down Expand Up @@ -44,13 +44,24 @@
// Open URL cross-platform
function openUrl(url) {
if (!url) return;
const cmd =
process.platform === "win32"
? `start "" "${url}"`
: process.platform === "darwin"
? `open "${url}"`
: `xdg-open "${url}"`;
exec(cmd);

if (process.platform === "win32") {
const child = spawn(process.env.comspec || "cmd.exe", ["/c", "start", "", url], {
detached: true,
stdio: "ignore",
shell: false,
});
Comment on lines +49 to +53
child.unref();
return;
}

const opener = process.platform === "darwin" ? "open" : "xdg-open";
const child = spawn(opener, [url], {
detached: true,
stdio: "ignore",
shell: false,
});
child.unref();
}

// Load resources from local file or fetch remotely
Expand Down
Loading