Skip to content

Commit 98bb2d7

Browse files
authored
Merge pull request #127 from gonX/validate-json-paths
Validate JSON directory paths
2 parents 74b6f32 + 4e3122f commit 98bb2d7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

validate.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ test_dependencies() {
2525
test_dep "sha256sum"
2626
test_dep "jq"
2727
test_dep "xargs"
28+
test_dep "find"
29+
}
30+
31+
test_repository_structure() {
32+
cd "${ROOTDIR}"
33+
if [ ! -d "Repository" ]; then
34+
print_clr ${ERROR} " Repository is missing expected 'Repository' folder"
35+
exit 104
36+
fi
37+
while read LINE; do
38+
if ! [[ "$LINE" =~ ^Repository/[0-9]([.][0-9]){3}(/[^/]+){2}/[^/]+json$ ]]; then
39+
error=$?
40+
print_clr ${ERROR} " FAIL: Invalid path ${LINE}"
41+
fi
42+
done < <(find Repository/ -iname '*.json' -type f)
43+
44+
[ ! -z "$error" ] && exit $error
45+
print_clr ${SUCCESS} " SUCCESS: Repository directory structure"
2846
}
2947

3048
check_sha256() {
@@ -53,6 +71,7 @@ validate() {
5371
}
5472

5573
test_dependencies
74+
test_repository_structure
5675

5776
for file in ${ROOTDIR}/**; do
5877
[ "${file: -5}" == ".json" ] && validate "${file}"

0 commit comments

Comments
 (0)