Skip to content

Commit

Permalink
Added summary on warnings and errors (#2581) (#2583)
Browse files Browse the repository at this point in the history
* feat: added a message summarizing the number of errors and warnings if there are any, fix: VERSION property is readonly

* tests: added test for errors and warnings summary message

* tests: added test for errors and warnings summary message (generateJson)

* chore: added a comment

* fix: typescript errors

* fix: fixed warnings by prettier

* refactor: moved logRunSummary to cli

* fix: lint issues
  • Loading branch information
bladerunner2020 authored and Gerrit0 committed Jun 12, 2024
1 parent d8de993 commit 7dee233
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,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 @@ -578,6 +578,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(this.i18n.docs_could_not_be_generated());
} else {
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 @@ -137,3 +138,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.`);
}
}

0 comments on commit 7dee233

Please sign in to comment.