@zgeoff/chex 0.3.14 → 0.3.16
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/package.json
CHANGED
package/src/docs/check-length.sh
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Checks each README against its line limit and each docs/ file against its cap. A README over its
|
|
3
3
|
# limit fails the run; a README over its target and a docs/ file over its cap print a warning and
|
|
4
|
-
# never fail it.
|
|
4
|
+
# never fail it. The front page README warns from 101 to 150 lines and fails over 150. The script's
|
|
5
|
+
# last line counts the READMEs and those over their limit.
|
|
5
6
|
# Usage (from the repo root): check-length.sh
|
|
6
7
|
# A README's limit comes from its path alone: the root README and each packages/*/README.md take the
|
|
7
8
|
# front page and package limits, and every other README takes the folder limit. A spike README under
|
|
@@ -50,16 +51,18 @@ count_lines() {
|
|
|
50
51
|
awk 'END { print NR }' "$1"
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
# Prints the README's target, limit and kind.
|
|
54
|
+
# Prints the README's target, warning threshold, limit and kind. Between the threshold and the
|
|
55
|
+
# limit, a README warns and passes. Package and folder READMEs set the threshold to their limit, so
|
|
56
|
+
# they never get the threshold warning.
|
|
54
57
|
pick_readme_kind() {
|
|
55
58
|
local readme=$1
|
|
56
59
|
|
|
57
60
|
if [ "$readme" = README.md ]; then
|
|
58
|
-
echo '80 100 front page'
|
|
61
|
+
echo '80 100 150 front page'
|
|
59
62
|
elif [[ $readme == packages/*/README.md && $readme != packages/*/*/README.md ]]; then
|
|
60
|
-
echo '80 100 package'
|
|
63
|
+
echo '80 100 100 package'
|
|
61
64
|
else
|
|
62
|
-
echo '60 70 folder'
|
|
65
|
+
echo '60 70 70 folder'
|
|
63
66
|
fi
|
|
64
67
|
}
|
|
65
68
|
|
|
@@ -84,13 +87,15 @@ readme_list=$(
|
|
|
84
87
|
while IFS= read -r readme; do
|
|
85
88
|
[ -n "$readme" ] || continue
|
|
86
89
|
readmes=$((readmes + 1))
|
|
87
|
-
read -r target limit name <<< "$(pick_readme_kind "$readme")"
|
|
90
|
+
read -r target warn limit name <<< "$(pick_readme_kind "$readme")"
|
|
88
91
|
lines=$(count_lines "$readme")
|
|
89
92
|
|
|
90
93
|
if [ "$lines" -gt "$limit" ]; then
|
|
91
94
|
fail=1
|
|
92
95
|
over_limit=$((over_limit + 1))
|
|
93
96
|
echo "$readme: $lines lines, over the $name README limit of $limit (target $target; error)"
|
|
97
|
+
elif [ "$lines" -gt "$warn" ]; then
|
|
98
|
+
echo "$readme: $lines lines, over the $name README warning threshold of $warn (target $target, limit $limit; warning)"
|
|
94
99
|
elif [ "$lines" -gt "$target" ]; then
|
|
95
100
|
echo "$readme: $lines lines, over the $name README target of $target (limit $limit; warning)"
|
|
96
101
|
else
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { lstatSync } from 'node:fs';
|
|
2
2
|
import { dirname, join, relative, sep } from 'node:path';
|
|
3
3
|
|
|
4
|
-
// Returns a probe for a file under the repo root. A path
|
|
5
|
-
//
|
|
4
|
+
// Returns a probe for a file under the repo root. A path reads as absent when a folder below the root
|
|
5
|
+
// is a link (git tracks no file beyond a link) or when it is a folder itself (a deleted path comes
|
|
6
|
+
// back only as a file or a link). Neither is a restored copy.
|
|
6
7
|
export function makeFileProbe(root: string): (path: string) => boolean {
|
|
7
8
|
return (path) => {
|
|
8
9
|
const folders = relative(root, dirname(path))
|
|
@@ -16,6 +17,12 @@ export function makeFileProbe(root: string): (path: string) => boolean {
|
|
|
16
17
|
})?.isSymbolicLink() === true,
|
|
17
18
|
);
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
if (linked) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const entry = lstatSync(path, { throwIfNoEntry: false });
|
|
25
|
+
|
|
26
|
+
return entry !== undefined && !entry.isDirectory();
|
|
20
27
|
};
|
|
21
28
|
}
|