specli 0.0.9 → 0.0.11

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/specli.js +22 -13
  2. package/package.json +1 -1
package/bin/specli.js CHANGED
@@ -1,17 +1,26 @@
1
- // Runtime-aware CLI entry point
2
- // - In Bun: runs cli.ts directly (TypeScript, full features including compile)
3
- // - In Node.js: runs dist/cli.js (compiled JS, exec only)
1
+ #!/usr/bin/env node
2
+ import { spawn } from "node:child_process";
4
3
 
5
- import { dirname, join } from "node:path";
6
- import { fileURLToPath } from "node:url";
4
+ const isBun = typeof globalThis.Bun !== "undefined";
5
+ const isCompileCommand = process.argv.includes("compile");
7
6
 
8
- const __dirname = dirname(fileURLToPath(import.meta.url));
9
- const root = join(__dirname, "..");
10
-
11
- if (typeof globalThis.Bun !== "undefined") {
12
- // Running in Bun - import TypeScript directly
13
- await import(join(root, "cli.ts"));
7
+ if (!isBun && isCompileCommand) {
8
+ // Re-run with Bun for compile command
9
+ const child = spawn("bun", process.argv.slice(1), {
10
+ stdio: "inherit",
11
+ });
12
+ child.on("close", (code) => process.exit(code ?? 0));
13
+ child.on("error", (err) => {
14
+ if (err.code === "ENOENT") {
15
+ console.error("Error: The 'compile' command requires Bun.");
16
+ console.error("Install Bun: https://bun.sh");
17
+ process.exit(1);
18
+ }
19
+ throw err;
20
+ });
14
21
  } else {
15
- // Running in Node.js - use compiled JS
16
- await import(join(root, "dist", "cli.js"));
22
+ // Run the CLI directly
23
+ const root = new URL("..", import.meta.url).pathname;
24
+ const entry = isBun ? `${root}cli.ts` : `${root}dist/cli.js`;
25
+ await import(entry);
17
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specli",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",