@lovrozagar/grunt 0.8.0 → 0.8.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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/scripts/folder-map.mjs +13 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.8.1] - 2026-10-03
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- `grunt map <dir>` printed nothing on Windows: the scope dir is now resolved with `git rev-parse --show-prefix`, so 8.3 short paths and symlinked roots match git's paths. A missing scope dir prints an empty map
|
|
15
|
+
|
|
10
16
|
## [0.8.0] - 2026-10-03
|
|
11
17
|
|
|
12
18
|
### Added
|
package/package.json
CHANGED
package/scripts/folder-map.mjs
CHANGED
|
@@ -60,12 +60,22 @@ function git(args, cwd) {
|
|
|
60
60
|
return r.status === 0 ? r.stdout : null;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
/** Repo top
|
|
63
|
+
/** Repo top, or null outside git. */
|
|
64
64
|
export function repoRoot(cwd) {
|
|
65
65
|
const top = git(["rev-parse", "--show-toplevel"], cwd);
|
|
66
66
|
return top ? top.trim() : null;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Repo-relative posix path of `abs` ("" at the top), or null when it is not a
|
|
71
|
+
* dir in a repo. Asks git so Windows short (8.3) vs long paths cannot diverge.
|
|
72
|
+
*/
|
|
73
|
+
export function repoPrefix(abs) {
|
|
74
|
+
if (!fs.existsSync(abs) || !fs.statSync(abs).isDirectory()) return null;
|
|
75
|
+
const prefix = git(["rev-parse", "--show-prefix"], abs);
|
|
76
|
+
return prefix == null ? null : prefix.trim().replace(/\/$/, "");
|
|
77
|
+
}
|
|
78
|
+
|
|
69
79
|
/** Tracked + untracked-unignored files, repo-relative, posix. */
|
|
70
80
|
export function listFiles(root) {
|
|
71
81
|
const out = git(["ls-files", "-z", "--cached", "--others", "--exclude-standard"], root);
|
|
@@ -271,7 +281,8 @@ export function folderMap({ root, dir = "", ...opts } = {}) {
|
|
|
271
281
|
const files = listFiles(top);
|
|
272
282
|
if (!files) return null;
|
|
273
283
|
const o = { ...loadMapConfig(top), ...opts };
|
|
274
|
-
const scope = dir ?
|
|
284
|
+
const scope = dir ? repoPrefix(path.resolve(root, dir)) : "";
|
|
285
|
+
if (scope == null) return { text: "", rows: 0, tokens: 0 };
|
|
275
286
|
const scoped = scope
|
|
276
287
|
? files.filter((f) => f.startsWith(`${scope}/`)).map((f) => f.slice(scope.length + 1))
|
|
277
288
|
: files;
|