Skip to content

Commit f0bd5a3

Browse files
committed
Fixed an issue where warnings would cause the api-extractor tool to return a nonzero exit code for a "--local" build; warnings should not fail the build in this scenario
1 parent 18b3e7b commit f0bd5a3

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

‎apps/api-extractor/src/extractor/Extractor.ts‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,13 @@ export class Extractor {
183183
* Invokes the API Extractor engine, using the configuration that was passed to the constructor.
184184
* @param options - provides additional runtime state that is NOT part of the API Extractor
185185
* config file.
186-
* @returns true if there were no errors or warnings; false if the tool chain should fail the build
186+
* @returns true for a successful build, or false if the tool chain should fail the build
187+
*
188+
* @remarks
189+
*
190+
* This function returns false to indicate that the build failed, i.e. the command-line tool
191+
* would return a nonzero exit code. Normally the build fails if there are any errors or
192+
* warnings; however, if options.localBuild=true then warnings are ignored.
187193
*/
188194
public processProject(options?: IAnalyzeProjectOptions): boolean {
189195
this._monitoredLogger.resetCounters();
@@ -293,8 +299,13 @@ export class Extractor {
293299
packageTypingsGenerator.writeTypingsFile(dtsFilename);
294300
}
295301

296-
// If there were any errors or warnings, then fail the build
297-
return (this._monitoredLogger.errorCount + this._monitoredLogger.warningCount) === 0;
302+
if (this._localBuild) {
303+
// For a local build, fail if there were errors (but ignore warnings)
304+
return this._monitoredLogger.errorCount === 0;
305+
} else {
306+
// For a production build, fail if there were any errors or warnings
307+
return (this._monitoredLogger.errorCount + this._monitoredLogger.warningCount) === 0;
308+
}
298309
}
299310

300311
private _getShortFilePath(absolutePath: string): string {
@@ -303,5 +314,4 @@ export class Extractor {
303314
}
304315
return path.relative(this._absoluteRootFolder, absolutePath).replace(/\\/g, '/');
305316
}
306-
307317
}

0 commit comments

Comments
 (0)