Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tvillaren committed Feb 19, 2024
1 parent 7edc41e commit af4edc8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,26 @@ See more help with --help`,
if (!Flags.skipValidation) {
const validatorSpinner = ora("Validating generated types").start();
if (Flags.all) validatorSpinner.indent = 1;

const extraFiles = [];
for (const io of inputOutputMappings) {
if (getImportPath(inputPath, io.input) !== "/") {
const fileInputPath = join(process.cwd(), io.input);
const inputFile = await readFile(fileInputPath, "utf-8");
extraFiles.push({
sourceText: inputFile,
relativePath: getImportPath(inputPath, io.input) + ".ts",
});

const fileOutputPath = join(process.cwd(), io.output);
const outputFile = await readFile(fileOutputPath, "utf-8");
extraFiles.push({
sourceText: outputFile,
relativePath: getImportPath(outputPath, io.output) + ".ts",
});
}
}

const generationErrors = await worker.validateGeneratedTypesInWorker({
sourceTypes: {
sourceText: transformedSourceText,
Expand All @@ -314,6 +334,7 @@ See more help with --help`,
relativePath: "./source.zod.ts",
},
skipParseJSDoc: Boolean(generateOptions.skipParseJSDoc),
extraFiles,
});

generationErrors.length
Expand Down

0 comments on commit af4edc8

Please sign in to comment.