Skip to content

Commit 63951c8

Browse files
committed
Always generate schema.json when running validate-rules
1 parent c3eb6d6 commit 63951c8

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"lint": "eslint . && prettier . --check && npm run validate-rules",
2222
"bundle": "./build.sh",
2323
"generate-rule-schema": "ts-node scripts/generate-rule-schema.ts",
24-
"validate-rules": "ts-node scripts/validate-rules.ts",
24+
"validate-rules": "npm run generate-rule-schema && ts-node scripts/validate-rules.ts",
2525
"watch": "npm run prepublish && chokidar \"lib\" \"addon\" \"rules/autoconsent\" \"rules/filterlist.txt\" --ignore 'lib/filterlist-engine.ts' -c \"npm run prepublish\"",
2626
"create-rule": "node rules/create-rule.mjs",
2727
"test": "playwright test",

scripts/validate-rules.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Ajv, { ErrorObject } from 'ajv';
22
import { readdirSync, readFileSync, existsSync } from 'fs';
33
import path from 'path';
4-
import { execSync } from 'child_process';
54

65
function formatErrors(errors: ErrorObject[]) {
76
if (!Array.isArray(errors)) {
@@ -10,11 +9,10 @@ function formatErrors(errors: ErrorObject[]) {
109
return errors.map((item) => `${item.instancePath}: ${item.message}`).join(', ');
1110
}
1211

13-
// Check if schema exists, if not generate it
1412
const schemaPath = path.join(__dirname, '../rules/schema.json');
1513
if (!existsSync(schemaPath)) {
16-
console.log('Schema not found, generating...');
17-
execSync('ts-node scripts/generate-rule-schema.ts');
14+
console.error(`Schema file does not exist at: ${schemaPath}`);
15+
process.exit(1);
1816
}
1917

2018
const schema = JSON.parse(readFileSync(schemaPath, 'utf8'));

0 commit comments

Comments
 (0)