code-guardrails 0.3.2 → 0.3.4

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/guardrails +20 -17
  2. package/package.json +6 -6
package/bin/guardrails CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { spawnSync } = require("child_process");
3
+ const { spawnSync, execFileSync } = require("child_process");
4
+ const { existsSync } = require("fs");
4
5
  const path = require("path");
5
6
 
6
7
  const PLATFORMS = {
@@ -33,23 +34,25 @@ function getBinaryPath() {
33
34
 
34
35
  const binaryName = process.platform === "win32" ? "guardrails.exe" : "guardrails";
35
36
 
36
- try {
37
- // Resolve from the package's node_modules, not the script's location
38
- const pkgDir = path.resolve(__dirname, "..");
39
- return require.resolve(path.join(pkg, binaryName), {
40
- paths: [pkgDir, path.join(pkgDir, "node_modules"), ...require.resolve.paths(pkg) || []],
41
- });
42
- } catch {
43
- console.error(
44
- `Could not find the binary for ${pkg}.\n` +
45
- `This usually means the optional dependency was not installed.\n\n` +
46
- `Try reinstalling:\n` +
47
- ` npm install -g code-guardrails\n\n` +
48
- `Or install from source:\n` +
49
- ` cargo install guardrails\n`
50
- );
51
- process.exit(1);
37
+ // Both packages live as siblings in the same node_modules directory
38
+ // __dirname = .../node_modules/code-guardrails/bin
39
+ // sibling = .../node_modules/<platform-pkg>/guardrails
40
+ const nodeModulesDir = path.resolve(__dirname, "..", "..");
41
+ const binaryPath = path.join(nodeModulesDir, pkg, binaryName);
42
+
43
+ if (existsSync(binaryPath)) {
44
+ return binaryPath;
52
45
  }
46
+
47
+ console.error(
48
+ `Could not find the binary for ${pkg}.\n` +
49
+ `This usually means the optional dependency was not installed.\n\n` +
50
+ `Try reinstalling:\n` +
51
+ ` npm install -g code-guardrails\n\n` +
52
+ `Or install from source:\n` +
53
+ ` cargo install guardrails\n`
54
+ );
55
+ process.exit(1);
53
56
  }
54
57
 
55
58
  const binary = getBinaryPath();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-guardrails",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Enforce architectural decisions AI coding tools keep ignoring",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,11 +14,11 @@
14
14
  "bin/guardrails"
15
15
  ],
16
16
  "optionalDependencies": {
17
- "code-guardrails-darwin-arm64": "0.3.2",
18
- "code-guardrails-darwin-x64": "0.3.2",
19
- "code-guardrails-linux-x64": "0.3.2",
20
- "code-guardrails-linux-arm64": "0.3.2",
21
- "code-guardrails-win32-x64": "0.3.2"
17
+ "code-guardrails-darwin-arm64": "0.3.4",
18
+ "code-guardrails-darwin-x64": "0.3.4",
19
+ "code-guardrails-linux-x64": "0.3.4",
20
+ "code-guardrails-linux-arm64": "0.3.4",
21
+ "code-guardrails-win32-x64": "0.3.4"
22
22
  },
23
23
  "keywords": [
24
24
  "linter",