@muxcodecli/cli 1.15.13 → 1.15.15

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/bin/muxcode CHANGED
@@ -1,35 +1,29 @@
1
1
  #!/usr/bin/env node
2
- const { execFileSync, spawnSync } = require("child_process")
2
+ const { spawnSync } = require("child_process")
3
3
  const path = require("path")
4
- const os = require("os")
5
4
  const fs = require("fs")
6
5
 
7
- const platform = os.platform()
8
- const arch = os.arch()
9
- const dir = path.dirname(fs.realpathSync(__filename))
10
-
11
- const binMap = {
12
- "linux-x64": "muxcode-linux-x64",
13
- "linux-arm64": "muxcode-linux-arm64",
14
- "darwin-x64": "muxcode-darwin-x64",
15
- "darwin-arm64": "muxcode-darwin-arm64",
16
- }
17
-
18
- const key = `${platform}-${arch}`
19
- const bin = binMap[key]
20
-
21
- if (!bin) {
22
- console.error(`Unsupported platform: ${key}`)
23
- process.exit(1)
6
+ function findBun() {
7
+ // 1. bun npm package
8
+ try {
9
+ const p = path.join(path.dirname(require.resolve("bun/package.json")), "bin", "bun")
10
+ if (fs.existsSync(p)) return p
11
+ } catch {}
12
+ // 2. bun no PATH
13
+ const cmd = process.platform === "win32" ? "where bun" : "which bun"
14
+ try {
15
+ const { execSync } = require("child_process")
16
+ return execSync(cmd, { encoding: "utf8" }).trim().split("\n")[0].trim()
17
+ } catch {}
18
+ return null
24
19
  }
25
20
 
26
- const binPath = path.join(dir, "..", "dist", bin)
27
-
28
- if (!fs.existsSync(binPath)) {
29
- console.error(`Binary not found: ${binPath}`)
30
- console.error(`Run: npm install -g @muxcodecli/cli`)
21
+ const bun = findBun()
22
+ if (!bun) {
23
+ console.error("muxcode requires bun. Install: npm install -g bun")
31
24
  process.exit(1)
32
25
  }
33
26
 
34
- const result = spawnSync(binPath, process.argv.slice(2), { stdio: "inherit" })
27
+ const bundle = path.join(__dirname, "..", "dist", "index.js")
28
+ const result = spawnSync(bun, [bundle, ...process.argv.slice(2)], { stdio: "inherit" })
35
29
  process.exit(result.status ?? 0)