mushroomdb 0.6.0 → 0.6.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.
Files changed (2) hide show
  1. package/bin/mushroomdb.js +34 -1
  2. package/package.json +1 -1
package/bin/mushroomdb.js CHANGED
@@ -5,7 +5,40 @@ const { spawnSync } = require("child_process");
5
5
  const fs = require("fs");
6
6
  const path = require("path");
7
7
 
8
- const bin = path.join(__dirname, "..", "vendor", "mushroomdb");
8
+ const bin = path.resolve(path.join(__dirname, "..", "vendor", "mushroomdb"));
9
+
10
+ // Two flags that answer "where is this package", so an installer can ask once
11
+ // instead of making every invocation pay for `npx`.
12
+ //
13
+ // Resolving the package costs npx a cache check, a version resolve and a Node
14
+ // process of its own — around half a second — and a Claude Code hook would pay
15
+ // that before every prompt and every edit. `mushroomdb install` and the plugin's
16
+ // hooks/run.sh ask once and write the answer down.
17
+ //
18
+ // Prefer `--print-binary`. This script is only a shim: it starts a Node
19
+ // runtime and then spawns the native binary anyway, and that Node startup is
20
+ // most of the cost. Measured warm, `--version`: npx 514 ms, `node <this file>`
21
+ // 118 ms, the binary directly 7 ms. `--print-launcher` stays as the fallback
22
+ // for an install whose vendored binary was never fetched.
23
+
24
+ // The native binary for this platform, which postinstall put beside us.
25
+ // Exits 1 when it is not there, so a caller can fall through to the launcher.
26
+ if (process.argv[2] === "--print-binary") {
27
+ if (!fs.existsSync(bin)) {
28
+ process.stderr.write("mushroomdb binary is missing at " + bin + "\n");
29
+ process.exit(1);
30
+ }
31
+ process.stdout.write(bin + "\n");
32
+ process.exit(0);
33
+ }
34
+
35
+ // This script's own path. Answered before the vendor check on purpose: where
36
+ // this file is stays true whether or not the binary beside it was fetched.
37
+ if (process.argv[2] === "--print-launcher") {
38
+ process.stdout.write(__filename + "\n");
39
+ process.exit(0);
40
+ }
41
+
9
42
  if (!fs.existsSync(bin)) {
10
43
  process.stderr.write(
11
44
  "mushroomdb binary is missing; re-run npm install (postinstall fetches the GitHub Release asset)\n",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mushroomdb",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Launcher for the mushroomdb native binary (downloaded from GitHub Releases).",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "repository": {