Output compiled validator to source tree as well

Output message_validate.js to both dist/src/data and src/data. This
allows tools to directly consume the TypeScript sources in src/data
without throwing an error due to message_validate being missing.
This commit is contained in:
Hornwitser committed 2023-11-28 15:35:40 +01:00
1 parent ceb7e48c99
commit 8b5c66d900
3 files changed
+9 -4

No files matched your search

+1
View File
@@ -0,0 +1 @@
/src/data/message_validate.js
View File
Whitespace-only changes.
+8 -4
View File
@@ -22,7 +22,11 @@ const ajv = new Ajv({
});
const validate = ajv.compile(Message.jsonSchema);
let moduleCode = standaloneCode(ajv, validate);
fs.outputFileSync(
path.join(__dirname, "../dist/src/data/message_validate.js"),
`// generated by scripts/compile_validator.js\n// @ts-nocheck\n/* eslint-disable */\n${moduleCode}`
);
function write(output) {
fs.outputFileSync(
path.join(__dirname, output),
`// generated by scripts/compile_validator.js\n// @ts-nocheck\n/* eslint-disable */\n${moduleCode}`
);
}
write("../dist/src/data/message_validate.js");
write("../src/data/message_validate.js");