Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added summary on warnings and errors (#2581) #2583

Merged
merged 8 commits into from
Jun 11, 2024
4 changes: 3 additions & 1 deletion src/lib/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class Application extends ChildableComponent<
/**
* The version number of TypeDoc.
*/
static VERSION = packageInfo.version;
static readonly VERSION = packageInfo.version;

/**
* Emitted after plugins have been loaded and options have been read, but before they have been frozen.
Expand Down Expand Up @@ -525,6 +525,7 @@ export class Application extends ChildableComponent<
const start = Date.now();
out = Path.resolve(out);
await this.renderer.render(project, out);

if (this.logger.hasErrors()) {
this.logger.error(
"Documentation could not be generated due to the errors above.",
Expand All @@ -551,6 +552,7 @@ export class Application extends ChildableComponent<

const space = this.options.getValue("pretty") ? "\t" : "";
await writeFile(out, JSON.stringify(ser, null, space));

this.logger.info(`JSON written to ${nicePath(out)}`);
this.logger.verbose(`JSON rendering took ${Date.now() - start}ms`);
}
Expand Down
15 changes: 15 additions & 0 deletions src/lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ async function main() {
const exitCode = await run(app);
if (exitCode !== ExitCodes.Watching) {
app.logger.verbose(`Full run took ${Date.now() - start}ms`);
logRunSummary(app.logger);
process.exit(exitCode);
}
} catch (error) {
Expand Down Expand Up @@ -135,3 +136,17 @@ async function run(app: td.Application) {

return ExitCodes.Ok;
}

/**
* Generate a string with the number of errors and warnings found.
*/
function logRunSummary(logger: td.Logger): void {
const { errorCount, warningCount } = logger;
if (errorCount) {
logger.error(
`Found: ${errorCount} error(s), ${warningCount} warnings.`,
);
} else if (warningCount) {
logger.warn(`Found: ${errorCount} error(s), ${warningCount} warnings.`);
}
}
Loading