specv 0.4.0 → 0.4.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/README.md CHANGED
@@ -14,20 +14,14 @@ A CLI tool that previews Markdown files in the current directory with GitHub-sty
14
14
  - GitHub dark theme color scheme
15
15
  - Automatic port detection (tries next port on conflict)
16
16
 
17
- ## Install
18
-
19
- ```bash
20
- npm install -g specv
21
- ```
22
-
23
17
  ## Usage
24
18
 
25
19
  ```bash
26
20
  # Preview .md files in the current directory
27
- specv
21
+ npx specv@latest
28
22
 
29
23
  # Specify a port
30
- specv -p 3000
24
+ npx specv@latest -p 3000
31
25
  ```
32
26
 
33
27
  A browser window opens automatically, rendering your Markdown files with GitHub-style formatting.
@@ -347,12 +347,26 @@ data: ${msg.data}
347
347
  return api;
348
348
  };
349
349
 
350
- // src/server/cli.ts
351
- var currentDir = import.meta.dirname;
350
+ // src/server/open-browser.ts
351
+ import { execFile as execFileCb } from "child_process";
352
+ import { promisify } from "util";
353
+ var execFile = promisify(execFileCb);
354
+ var getCommand = (url) => {
355
+ if (process.platform === "darwin") {
356
+ return { args: [url], command: "open" };
357
+ }
358
+ if (process.platform === "win32") {
359
+ return { args: ["/c", "start", "", url], command: "cmd" };
360
+ }
361
+ return { args: [url], command: "xdg-open" };
362
+ };
352
363
  var openInBrowser = async (url) => {
353
- const mod = await import("open");
354
- await mod.default(url);
364
+ const { args, command } = getCommand(url);
365
+ await execFile(command, args);
355
366
  };
367
+
368
+ // src/server/cli.ts
369
+ var currentDir = import.meta.dirname;
356
370
  var DISCONNECT_GRACE_MS = 2e3;
357
371
  var registerLifecycle = (app, onDisconnect) => {
358
372
  let connections = 0;
@@ -426,8 +440,8 @@ program.name("specv").description("Local Markdown preview with GitHub-style rend
426
440
  console.log("Press Ctrl+C to stop");
427
441
  try {
428
442
  await openInBrowser(url);
429
- } catch (error) {
430
- console.error("Failed to open browser:", error);
443
+ } catch {
444
+ console.log(`Open ${url} in your browser`);
431
445
  }
432
446
  }
433
447
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specv",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Local Markdown preview with GitHub-style rendering",
5
5
  "keywords": [
6
6
  "cli",
@@ -46,7 +46,6 @@
46
46
  "hono": "^4.12.7",
47
47
  "katex": "^0.16.38",
48
48
  "mermaid": "^11.13.0",
49
- "open": "^11.0.0",
50
49
  "rehype-autolink-headings": "^7.1.0",
51
50
  "rehype-katex": "^7.0.1",
52
51
  "rehype-raw": "^7.0.0",