@@ -6,7 +6,11 @@ import * as path from 'path';
66import * as through from 'through2' ;
77import * as gulpUtil from 'gulp-util' ;
88import { GulpTask } from '@microsoft/gulp-core-build' ;
9- import { Analyzer , IApiAnalyzerOptions , ApiFileGenerator , ApiJsonGenerator } from '@microsoft/api-extractor' ;
9+ import { Extractor ,
10+ IExtractorOptions ,
11+ IApiAnalyzerOptions ,
12+ ApiFileGenerator ,
13+ ApiJsonGenerator } from '@microsoft/api-extractor' ;
1014import { TypeScriptConfiguration } from './TypeScriptConfiguration' ;
1115import * as typescript from 'typescript' ; /* tslint:disable-line */
1216
@@ -91,19 +95,22 @@ export class ApiExtractorTask extends GulpTask<IApiExtractorTaskConfig> {
9195 const compilerOptions : typescript . CompilerOptions =
9296 TypeScriptConfiguration . getTypescriptOptions ( this . buildConfig ) . compilerOptions ;
9397
98+ const extractorOptions : IExtractorOptions = {
99+ compilerOptions : compilerOptions ,
100+ errorHandler : ( message : string , fileName : string , lineNumber : number ) : void => {
101+ this . logWarning ( `${ message } ` + os . EOL
102+ + ` ${ fileName } #${ lineNumber } ` ) ;
103+ }
104+ } ;
105+
94106 const analyzerOptions : IApiAnalyzerOptions = {
95107 entryPointFile,
96- compilerOptions,
97108 otherFiles
98109 } as any ; /* tslint:disable-line:no-any */
99110
100- const analyzer : Analyzer = new Analyzer (
101- ( message : string , fileName : string , lineNumber : number ) : void => {
102- this . logWarning ( `${ message } ` + os . EOL
103- + ` ${ fileName } #${ lineNumber } ` ) ;
104- }
105- ) ;
106- analyzer . analyze ( analyzerOptions ) ;
111+ const extractor : Extractor = new Extractor ( extractorOptions ) ;
112+ extractor . loadExternalPackages ( path . join ( __dirname , 'external-api-json' ) ) ;
113+ extractor . analyze ( analyzerOptions ) ;
107114
108115 const jsonGenerator : ApiJsonGenerator = new ApiJsonGenerator ( ) ;
109116 // const jsonContent: string = generator.generateJsonFileContent(analyzer);
@@ -120,11 +127,11 @@ export class ApiExtractorTask extends GulpTask<IApiExtractorTaskConfig> {
120127 if ( fsx . existsSync ( this . taskConfig . apiJsonFolder ) ) {
121128 const jsonFilePath : string = path . join ( this . taskConfig . apiJsonFolder , jsonFileName ) ;
122129 this . logVerbose ( `Writing Api JSON file to ${ jsonFilePath } ` ) ;
123- jsonGenerator . writeJsonFile ( jsonFilePath , analyzer ) ;
130+ jsonGenerator . writeJsonFile ( jsonFilePath , extractor ) ;
124131 }
125132
126133 const generator : ApiFileGenerator = new ApiFileGenerator ( ) ;
127- const actualApiFileContent : string = generator . generateApiFileContent ( analyzer ) ;
134+ const actualApiFileContent : string = generator . generateApiFileContent ( extractor ) ;
128135
129136 // Ex: "project.api.ts"
130137 const apiFileName : string = path . basename ( this . buildConfig . rootPath ) + '.api.ts' ;
0 commit comments