@kongyo2/ts-comment-scanner 1.5.0 → 1.6.0
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.en.md +4 -2
- package/README.md +4 -2
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +6 -2
- package/dist/args.js.map +1 -1
- package/dist/directives.d.ts.map +1 -1
- package/dist/directives.js +31 -19
- package/dist/directives.js.map +1 -1
- package/dist/files.d.ts +10 -2
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +91 -72
- package/dist/files.js.map +1 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/git.js +7 -2
- package/dist/git.js.map +1 -1
- package/dist/lines.d.ts +18 -0
- package/dist/lines.d.ts.map +1 -0
- package/dist/lines.js +40 -0
- package/dist/lines.js.map +1 -0
- package/dist/remove.d.ts.map +1 -1
- package/dist/remove.js +60 -75
- package/dist/remove.js.map +1 -1
- package/dist/report.d.ts.map +1 -1
- package/dist/report.js +2 -2
- package/dist/report.js.map +1 -1
- package/dist/run.d.ts +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +16 -16
- package/dist/run.js.map +1 -1
- package/package.json +1 -1
- package/src/args.ts +5 -2
- package/src/directives.ts +29 -20
- package/src/files.ts +110 -71
- package/src/git.ts +6 -2
- package/src/lines.ts +43 -0
- package/src/remove.ts +61 -79
- package/src/report.ts +2 -2
- package/src/run.ts +16 -16
package/src/run.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { parseArgs, UsageError, type CliOptions, type DirectiveMode } from "./ar
|
|
|
5
5
|
import {
|
|
6
6
|
collectFiles,
|
|
7
7
|
encodeFileText,
|
|
8
|
+
foldPathCase,
|
|
8
9
|
isJsxFile,
|
|
9
10
|
mapLimit,
|
|
10
11
|
readFileText,
|
|
@@ -53,8 +54,11 @@ General:
|
|
|
53
54
|
-v, --version Print the version number
|
|
54
55
|
|
|
55
56
|
Paths default to the current directory. Directories are scanned recursively,
|
|
56
|
-
skipping node_modules and .git.
|
|
57
|
-
|
|
57
|
+
skipping node_modules and .git. Ignore globs without a slash match file names,
|
|
58
|
+
and a trailing slash (dist/) restricts a glob to directories. JavaScript files
|
|
59
|
+
(.js, .jsx, .mjs, .cjs) added with --ext are parsed with JSX enabled. Removal
|
|
60
|
+
keeps directives and license headers unless explicitly requested, so builds
|
|
61
|
+
and linters keep working.
|
|
58
62
|
|
|
59
63
|
--diff narrows any scan or removal to files changed in git: a single revision
|
|
60
64
|
compares the working tree against it (HEAD covers all uncommitted work,
|
|
@@ -142,31 +146,27 @@ async function collectTargets(options: CliOptions, collectOptions: CollectOption
|
|
|
142
146
|
// alias may point at the changed file), and either spelling names the same
|
|
143
147
|
// content. Broken links (a symlink re-pointed at nothing) only match by
|
|
144
148
|
// their reported spelling.
|
|
149
|
+
// Paths are folded the way the platform compares them: git reports the case
|
|
150
|
+
// a file was tracked with, so on Windows `Foo.ts` must stay in scope when
|
|
151
|
+
// the scan found it as `foo.ts`.
|
|
145
152
|
const changed = new Set<string>();
|
|
146
153
|
for (const path of await changedFiles(options.diff, anchor)) {
|
|
147
|
-
changed.add(
|
|
154
|
+
changed.add(foldPathCase(path));
|
|
148
155
|
const real = tryRealpath(path);
|
|
149
|
-
if (real !== undefined) changed.add(
|
|
156
|
+
if (real !== undefined) changed.add(foldPathCase(real));
|
|
150
157
|
}
|
|
151
158
|
// Realpath only the directory part first: spellings through symlinked
|
|
152
159
|
// directories then compare equal while a tracked symlink still matches the
|
|
153
|
-
// path git reports it at; the fully dereferenced path is the fallback.
|
|
160
|
+
// path git reports it at; the fully dereferenced path is the fallback. A
|
|
161
|
+
// directory that vanished since the walk is compared as spelled.
|
|
154
162
|
return files.filter((file) => {
|
|
155
|
-
|
|
163
|
+
const directory = tryRealpath(dirname(file)) ?? dirname(file);
|
|
164
|
+
if (changed.has(foldPathCase(join(directory, basename(file))))) return true;
|
|
156
165
|
const real = tryRealpath(file);
|
|
157
|
-
return real !== undefined && changed.has(
|
|
166
|
+
return real !== undefined && changed.has(foldPathCase(real));
|
|
158
167
|
});
|
|
159
168
|
}
|
|
160
169
|
|
|
161
|
-
/**
|
|
162
|
-
* Windows paths are case-insensitive, but git reports the case a file was
|
|
163
|
-
* tracked with; folding both sides keeps `Foo.ts` in the --diff scope when
|
|
164
|
-
* the scan found it as `foo.ts`.
|
|
165
|
-
*/
|
|
166
|
-
function caseFold(path: string): string {
|
|
167
|
-
return process.platform === "win32" ? path.toLowerCase() : path;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
170
|
/**
|
|
171
171
|
* Native realpath — changedFiles resolves the repository root with the
|
|
172
172
|
* (native) promises realpath, and on Windows only the native calls expand
|