@cldmv/fix-headers 1.2.2 → 1.2.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/README.md +5 -5
- package/package.json +1 -1
- package/src/header/parser.mjs +13 -3
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# fix-headers
|
|
1
|
+
# @cldmv/fix-headers
|
|
2
2
|
|
|
3
3
|
Multi-language source header normalizer for Node.js projects.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`@cldmv/fix-headers` scans project files, auto-detects project metadata (language, root, project name, git author/email), and inserts or updates standard file headers.
|
|
6
6
|
|
|
7
7
|
[![npm version]][npm_version_url] [![npm downloads]][npm_downloads_url] <!-- [![GitHub release]][github_release_url] -->[![GitHub downloads]][github_downloads_url] [![Last commit]][last_commit_url] <!-- [![Release date]][release_date_url] -->[![npm last update]][npm_last_update_url] [![Coverage]][coverage_url]
|
|
8
8
|
|
|
@@ -21,7 +21,7 @@ Multi-language source header normalizer for Node.js projects.
|
|
|
21
21
|
## Install
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
npm i fix-headers
|
|
24
|
+
npm i @cldmv/fix-headers
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## Usage
|
|
@@ -29,7 +29,7 @@ npm i fix-headers
|
|
|
29
29
|
### ESM
|
|
30
30
|
|
|
31
31
|
```js
|
|
32
|
-
import fixHeaders from "fix-headers";
|
|
32
|
+
import fixHeaders from "@cldmv/fix-headers";
|
|
33
33
|
|
|
34
34
|
const result = await fixHeaders({ dryRun: true });
|
|
35
35
|
```
|
|
@@ -70,7 +70,7 @@ Common CLI options:
|
|
|
70
70
|
### CommonJS
|
|
71
71
|
|
|
72
72
|
```js
|
|
73
|
-
const fixHeaders = require("fix-headers");
|
|
73
|
+
const fixHeaders = require("@cldmv/fix-headers");
|
|
74
74
|
|
|
75
75
|
const result = await fixHeaders({ dryRun: true });
|
|
76
76
|
```
|
package/package.json
CHANGED
package/src/header/parser.mjs
CHANGED
|
@@ -66,9 +66,19 @@ function matchHeaderSegment(content, syntax) {
|
|
|
66
66
|
return content.match(new RegExp(`^(?:${linePrefix}.*\\n)+\\n*`));
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
// Block comments (/* … */ family). A block comment opens with `/*` and is
|
|
70
|
+
// terminated by the FIRST `*/` after the opener (block comments do not nest in
|
|
71
|
+
// JS/JSONC/CSS/PHP). Match that real grammar rather than the detector's *styled*
|
|
72
|
+
// tokens: `blockStart` may be `/*` or `/**` (so anchor on `/*`, which prefixes
|
|
73
|
+
// both), and `blockEnd` carries a leading space (" */") that exists for GENERATION
|
|
74
|
+
// only. Using the styled " */" to bound an EXISTING header is the data-loss bug —
|
|
75
|
+
// any real closer that isn't byte-for-byte " */" (e.g. `**/`, a tab-indented `*/`,
|
|
76
|
+
// or `*/` at column 0) is skipped, so the lazy match runs on to the next `*/`
|
|
77
|
+
// downstream (inside a `//` line comment, a string literal, or another block) and
|
|
78
|
+
// everything in between is deleted on replace. Trim the styled space off so we stop
|
|
79
|
+
// at the header's own terminator.
|
|
80
|
+
const blockEnd = escapeRegex((syntax.blockEnd || " */").trim());
|
|
81
|
+
return content.match(new RegExp(`^/\\*[\\s\\S]*?${blockEnd}\\n*`));
|
|
72
82
|
}
|
|
73
83
|
|
|
74
84
|
/**
|