-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
Copy pathapiExtractor.js
36 lines (31 loc) · 1.04 KB
/
apiExtractor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const fs = require('fs-extra')
const path = require('path')
const colors = require('picocolors')
exports.extract = async function extract(target) {
const pkgDir = path.resolve(`packages/${target}`)
console.log()
console.log(
colors.bold(colors.yellow(`Rolling up type definitions for ${target}...`))
)
// build types
const { Extractor, ExtractorConfig } = require('@microsoft/api-extractor')
const extractorConfigPath = path.resolve(pkgDir, `api-extractor.json`)
const extractorConfig =
ExtractorConfig.loadFileAndPrepare(extractorConfigPath)
const extractorResult = Extractor.invoke(extractorConfig, {
localBuild: true,
showVerboseMessages: true,
})
if (extractorResult.succeeded) {
console.log(
colors.bold(colors.green(`API Extractor completed successfully.`))
)
} else {
console.error(
`API Extractor completed with ${extractorResult.errorCount} errors` +
` and ${extractorResult.warningCount} warnings`
)
process.exitCode = 1
}
await fs.remove(`${pkgDir}/dist/packages`)
}