@alumbwe/anvil 1.0.1 → 1.0.3

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/anvil.js ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * npm bin wrapper — launches the bundled CLI via bun.
4
+ *
5
+ * npm rejects shebangs other than `node`, so this thin shim exec's bun
6
+ * with the bundled entry point. When the user has bun installed globally
7
+ * (`npm i -g bun`) the CLI works out of the box.
8
+ */
9
+ const { execFileSync, spawnSync } = require('child_process');
10
+ const path = require('path');
11
+ const fs = require('fs');
12
+
13
+ const bundledPath = path.join(__dirname, '..', 'dist', 'bundled.js');
14
+
15
+ if (!fs.existsSync(bundledPath)) {
16
+ console.error(
17
+ 'Error: bundled CLI not found at ' + bundledPath + '\n' +
18
+ 'Try reinstalling: npm i -g @alumbwe/anvil',
19
+ );
20
+ process.exit(1);
21
+ }
22
+
23
+ // Try bun first (preferred), then fall back to node.
24
+ function tryRun(cmd, args) {
25
+ try {
26
+ const child = spawnSync(cmd, args, { stdio: 'inherit' });
27
+ if (child.error && child.error.code === 'ENOENT') return false;
28
+ process.exit(child.status ?? 1);
29
+ } catch {
30
+ return false;
31
+ }
32
+ }
33
+
34
+ if (!tryRun('bun', [bundledPath, ...process.argv.slice(2)])) {
35
+ if (!tryRun('node', [bundledPath, ...process.argv.slice(2)])) {
36
+ console.error(
37
+ 'Error: neither bun nor node found on PATH.\n' +
38
+ 'Install bun: https://bun.sh',
39
+ );
40
+ process.exit(1);
41
+ }
42
+ }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@alumbwe/anvil",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
7
- "anvil": "./bin/anvil"
7
+ "anvil": "./bin/anvil.js"
8
8
  },
9
9
  "files": [
10
- "bin/anvil",
10
+ "bin/anvil.js",
11
11
  "bin/tree-sitter.wasm",
12
12
  "dist/bundled.js",
13
13
  "dist/bundled.js.map"
package/bin/anvil DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env bun
2
- import '../dist/bundled.js'