@muxcodecli/cli 1.15.13 → 1.15.14

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,25 @@
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
+ // Tenta encontrar bun: primeiro @oven-sh/bun, depois PATH
7
+ function findBun() {
8
+ try {
9
+ const bunPkg = require.resolve("@oven-sh/bun/bin/bun")
10
+ if (fs.existsSync(bunPkg)) return bunPkg
11
+ } catch {}
12
+ const { execSync } = require("child_process")
13
+ try { return execSync("which bun || where bun", { encoding: "utf8" }).trim().split("\n")[0] } catch {}
14
+ return null
24
15
  }
25
16
 
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`)
17
+ const bun = findBun()
18
+ if (!bun) {
19
+ console.error("bun not found. Install via: npm install -g @oven-sh/bun")
31
20
  process.exit(1)
32
21
  }
33
22
 
34
- const result = spawnSync(binPath, process.argv.slice(2), { stdio: "inherit" })
23
+ const bundle = path.join(__dirname, "..", "dist", "index.js")
24
+ const result = spawnSync(bun, [bundle, ...process.argv.slice(2)], { stdio: "inherit" })
35
25
  process.exit(result.status ?? 0)