Skip to content

Commit adf47bd

Browse files
committed
Improve formatting of command-line output
1 parent 9ed425a commit adf47bd

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎apps/api-extractor/src/cli/ApiExtractorCommandLine.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4+
import * as os from 'os';
5+
import * as colors from 'colors';
6+
47
import { CommandLineParser } from '@microsoft/ts-command-line';
58
import { RunAction } from './RunAction';
69

@@ -16,6 +19,15 @@ export class ApiExtractorCommandLine extends CommandLineParser {
1619
protected onDefineParameters(): void { // override
1720
}
1821

22+
protected onExecute(): void { // override
23+
try {
24+
super.onExecute();
25+
} catch (error) {
26+
console.error(os.EOL + colors.red('ERROR: ' + error.message.trim()));
27+
process.exitCode = 1;
28+
}
29+
}
30+
1931
private _populateActions(): void {
2032
this.addAction(new RunAction(this));
2133
}

‎apps/api-extractor/src/cli/RunAction.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4+
import * as colors from 'colors';
45
import * as fsx from 'fs-extra';
56
import * as os from 'os';
67
import * as path from 'path';
@@ -84,7 +85,8 @@ export class RunAction extends CommandLineAction {
8485
});
8586

8687
if (!extractor.processProject()) {
87-
throw new Error('The build failed');
88+
console.log(os.EOL + colors.yellow('API Extractor completed with errors or warnings'));
89+
process.exitCode = 1;
8890
}
8991
}
9092
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ export class Extractor {
9797
public constructor(config: IExtractorConfig, options?: IExtractorOptions) {
9898
let mergedLogger: ILogger;
9999
if (options && options.customLogger) {
100-
mergedLogger = lodash.merge(lodash.cloneDeep(Extractor._defaultLogger),
101-
options.customLogger);
100+
mergedLogger = lodash.merge(lodash.clone(Extractor._defaultLogger), options.customLogger);
102101
} else {
103102
mergedLogger = Extractor._defaultLogger;
104103
}

0 commit comments

Comments
 (0)