Skip to content

Commit 58f1bac

Browse files
committed
feat: Add the --treatWarningsAsErrors option
Resolves #1568
1 parent bb5a5ae commit 58f1bac

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

bin/typedoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ async function run(app) {
5252
if (app.logger.hasErrors()) {
5353
return ExitCodes.OptionError;
5454
}
55+
if (
56+
app.options.getValue("treatWarningsAsErrors") &&
57+
app.logger.hasWarnings()
58+
) {
59+
return ExitCodes.OptionError;
60+
}
5561

5662
if (app.options.getValue("entryPoints").length === 0) {
5763
app.logger.error("No entry points provided");
@@ -97,5 +103,11 @@ async function run(app) {
97103
if (app.logger.hasErrors()) {
98104
return ExitCodes.OutputError;
99105
}
106+
if (
107+
app.options.getValue("treatWarningsAsErrors") &&
108+
app.logger.hasWarnings()
109+
) {
110+
return ExitCodes.OutputError;
111+
}
100112
return ExitCodes.Ok;
101113
}

src/lib/utils/options/declaration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export interface TypeDocOptionMap {
8080
plugin: string[];
8181
logger: unknown; // string | Function
8282
logLevel: typeof LogLevel;
83+
treatWarningsAsErrors: boolean;
8384
listInvalidSymbolLinks: boolean;
8485
markedOptions: unknown;
8586

src/lib/utils/options/sources/typedoc.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ export function addTypeDocOptions(options: Pick<Options, "addDeclaration">) {
260260
map: LogLevel,
261261
defaultValue: LogLevel.Info,
262262
});
263+
options.addDeclaration({
264+
name: "treatWarningsAsErrors",
265+
help: "If set, warnings will be treated as errors.",
266+
type: ParameterType.Boolean,
267+
});
263268
options.addDeclaration({
264269
name: "listInvalidSymbolLinks",
265270
help:

0 commit comments

Comments
 (0)