Skip to content

Commit ddd8fb0

Browse files
committed
fix(lib): json check robustness
1 parent 69fa05e commit ddd8fb0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/checks/json.check.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,15 @@ export function jsonCheckTaskFactory(definition: JSONCheckDefinition) {
5353
for (const file of files) {
5454
setTimeout(() => {
5555
let json;
56+
let result: any[];
5657
try {
5758
json = JSON.parse(stripJsonComments(fs.readFile(file)));
59+
result = JSONPath({
60+
path: jsonPropertyPath?.startsWith('$')
61+
? jsonPropertyPath
62+
: `$${jsonPropertyPath}`,
63+
json,
64+
});
5865
} catch (err: any) {
5966
errors.push(
6067
new Error(`[json] "${name}" - ${file} - ${err.message}`)
@@ -69,13 +76,6 @@ export function jsonCheckTaskFactory(definition: JSONCheckDefinition) {
6976
return;
7077
}
7178

72-
const result: any[] = JSONPath({
73-
path: jsonPropertyPath?.startsWith('$')
74-
? jsonPropertyPath
75-
: `$${jsonPropertyPath}`,
76-
json,
77-
});
78-
7979
if (result.length) {
8080
matches.push({
8181
file,

0 commit comments

Comments
 (0)