comment-crusher 0.0.0-bootstrap → 0.2.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fredrik Ryden
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # comment-crusher
2
+
3
+ Language-agnostic comment budget: fails a file whose comment-to-code ratio, comment block, or document length exceeds the budget the repo declares.
4
+
5
+ Installs the prebuilt binary for your platform as an optional dependency and runs it —
6
+ no Rust toolchain needed. Full docs and the config format: https://github.com/fredrikolis/comment-crusher
7
+
8
+ ```sh
9
+ npx comment-crusher .
10
+ ```
11
+
12
+ MIT. Built from https://github.com/fredrikolis/comment-crusher
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ const path = require("path");
4
+ const { spawnSync } = require("child_process");
5
+
6
+ const PLATFORM_PACKAGES = {
7
+ "linux-x64": "comment-crusher-linux-x64-musl",
8
+ "linux-arm64": "comment-crusher-linux-arm64-musl",
9
+ "darwin-x64": "comment-crusher-darwin-x64",
10
+ "darwin-arm64": "comment-crusher-darwin-arm64",
11
+ };
12
+
13
+ function resolveBinary() {
14
+ const key = `${process.platform}-${process.arch}`;
15
+ const pkg = PLATFORM_PACKAGES[key];
16
+ if (!pkg) return { key, pkg: null, bin: null };
17
+ try {
18
+ const pkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
19
+ return { key, pkg, bin: path.join(pkgDir, "comment-crusher") };
20
+ } catch (_err) {
21
+ return { key, pkg, bin: null };
22
+ }
23
+ }
24
+
25
+ const WRAPPER_FAILURE = 127; // the binary's own codes are verdicts about a file, not this
26
+
27
+ function fail(message) {
28
+ process.stderr.write(`comment-crusher: ${message}\n`);
29
+ process.exit(WRAPPER_FAILURE);
30
+ }
31
+
32
+ function main() {
33
+ const { key, pkg, bin } = resolveBinary();
34
+ if (!pkg) {
35
+ fail(
36
+ `unsupported platform ${key}. No prebuilt binary is published for it. ` +
37
+ "Build from source instead: cargo install comment-crusher"
38
+ );
39
+ }
40
+ if (!bin) {
41
+ fail(
42
+ `the prebuilt binary for ${key} is missing (expected package "${pkg}"). ` +
43
+ "Reinstall without skipping optional dependencies: npm install comment-crusher " +
44
+ `(do not pass --no-optional), or install "${pkg}" directly.`
45
+ );
46
+ }
47
+ const r = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
48
+ if (r.error) fail(r.error.message);
49
+ if (r.signal) {
50
+ process.removeAllListeners(r.signal);
51
+ process.kill(process.pid, r.signal);
52
+ }
53
+ process.exit(r.status === null ? WRAPPER_FAILURE : r.status);
54
+ }
55
+
56
+ main();
package/package.json CHANGED
@@ -1,16 +1,33 @@
1
1
  {
2
2
  "name": "comment-crusher",
3
- "version": "0.0.0-bootstrap",
3
+ "version": "0.2.1",
4
4
  "description": "Language-agnostic comment budget: fails a file whose comment-to-code ratio, comment block, or document length exceeds the budget the repo declares.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/fredrikolis/comment-crusher",
7
- "repository": { "type": "git", "url": "https://github.com/fredrikolis/comment-crusher.git" },
8
- "keywords": ["lint", "comments", "code-quality", "pre-commit", "cli"],
9
- "files": [],
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/fredrikolis/comment-crusher.git"
10
+ },
11
+ "keywords": [
12
+ "lint",
13
+ "comments",
14
+ "code-quality",
15
+ "pre-commit",
16
+ "cli"
17
+ ],
18
+ "bin": {
19
+ "comment-crusher": "bin/comment-crusher.js"
20
+ },
21
+ "files": [
22
+ "bin/comment-crusher.js"
23
+ ],
24
+ "engines": {
25
+ "node": ">=18"
26
+ },
10
27
  "optionalDependencies": {
11
- "comment-crusher-linux-x64-musl": "0.0.0-bootstrap",
12
- "comment-crusher-linux-arm64-musl": "0.0.0-bootstrap",
13
- "comment-crusher-darwin-x64": "0.0.0-bootstrap",
14
- "comment-crusher-darwin-arm64": "0.0.0-bootstrap"
28
+ "comment-crusher-linux-x64-musl": "0.2.1",
29
+ "comment-crusher-linux-arm64-musl": "0.2.1",
30
+ "comment-crusher-darwin-x64": "0.2.1",
31
+ "comment-crusher-darwin-arm64": "0.2.1"
15
32
  }
16
33
  }