Repository navigation
Improve api-extractor invocation so it's easier to determine failure - #451
Conversation
…ings; analyzeProject() is deprecated
|
|
||
| extractor.analyzeProject(); | ||
| if (!extractor.processProject()) { | ||
| console.log('processProject() failed the build'); |
There was a problem hiding this comment.
console.error #WontFix
There was a problem hiding this comment.
This file is only used for easier debugging during development; it's not part of the shipping code
In reply to: 152713831 [](ancestors = 152713831)
|
|
||
| // If there were any errors or warnings, then fail the build | ||
| return (this._monitoredLogger.errorCount + this._monitoredLogger.warningCount) === 0; | ||
| } |
There was a problem hiding this comment.
How about return the sum of error and warning? so that we know how many errors there are. #WontFix
There was a problem hiding this comment.
If the caller needs to report statistics, then I would prefer to return an actual statistics object with counts based on whatever reporting scenario there is.
However, currently I don't believe anyone has that requirement. Either they provide a custom logger (which gives them detailed access to everything) or else they just want to know whether the build should pass or fail.
In reply to: 152714377 [](ancestors = 152714377)
|
|
||
| // NOTE: processProject() returns false if errors or warnings occurred, however we | ||
| // already handle this above via our customLogger | ||
| extractor.processProject(); |
There was a problem hiding this comment.
how about adding if (resultHasError) { completeCallback('extractor failed with n errors'); }? #WontFix
There was a problem hiding this comment.
GCB already counts the number of errors and warnings that were passed to its custom logger and reports them like this:
Warning - tslint - src/Text.ts(41,12): error no-any: Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type, the empty type ('{}'), or suppress this occurrence.
Warning - tslint - src/Text.ts(41,9): error no-unused-variable: 'x' is declared but never used.
Warning - tslint - src/Text.ts(41,9): error prefer-const: Identifier 'x' is never reassigned; use 'const' instead of 'let'.
Warning - [api-extractor] You have changed the public API signature for this project. Updating ../../common/reviews/api/sp-core-library.api.ts
Error - [api-extractor] src/Text.ts(10,1): A release tag (@alpha, @beta, @public, @internal) must be specified for Text
[15:23:14] Project @microsoft/sp-core-library version: 1.4.0-dev.14
[15:23:14] Build tools version: 3.2.7
[15:23:14] Node version: v6.10.2
[15:23:14] Total duration: 12 s
[15:23:14] Task warnings: 4
[15:23:14] Task errors: 1
Thus, the api-extractor task doesn't need to maintain its own statistics.
In reply to: 152714393 [](ancestors = 152714393)
QZ (qz2017)
left a comment
There was a problem hiding this comment.
Approved with suggestions.
…or-detection Improve api-extractor invocation so it's easier to determine failure
If API Extractor reports warnings or errors, the build should fail. However, since
Extractor.analyzeProject()doesn't return a value, the only way to determine failure is by providing a customLogger. (This is what gulp-core-build does.) This PR adds a boolean return value to avoid this limitation.Based on feedback, we're also renaming
Extractor.analyzeProject()toExtractor.processProject().This PR also updates the api-extractor command-line tool to return a nonzero exit code if an error occurs.