Skip to content

Commit

Permalink
revert: API extractor API
Browse files Browse the repository at this point in the history
  • Loading branch information
Zamiell committed Nov 2, 2023
1 parent f00c2db commit acca18f
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions packages/isaacscript-common/scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Extractor, ExtractorConfig } from "@microsoft/api-extractor";
import {
$,
$sq,
appendFile,
buildScript,
cp,
fatalError,
rm,
} from "isaacscript-common-node";
import { assertDefined } from "isaacscript-common-ts";
Expand Down Expand Up @@ -32,7 +31,7 @@ await buildScript(async ({ packageRoot, outDir }) => {

rm(indexLuaTSPath);

scrubInternalExports(packageRoot);
scrubInternalExports();
});

/**
Expand All @@ -54,26 +53,7 @@ await buildScript(async ({ packageRoot, outDir }) => {
* not work:
* https://github.com/microsoft/rushstack/issues/1886
* https://github.com/timocov/dts-bundle-generator/issues/218
*
* Note that we deliberately invoke API extractor from its API. If we try to run it like this:
*
* ```ts
* $s`npx api-extractor run`; // `api-extractor` is noisy and we only care if it fails.
* ```
*
* Then it will cause a weird error in CI having to do with a "\r" character.
*/
function scrubInternalExports(packageRoot: string) {
const apiExtractorJSONPath = path.join(packageRoot, "api-extractor.json");
const extractorConfig =
ExtractorConfig.loadFileAndPrepare(apiExtractorJSONPath);
const extractorResult = Extractor.invoke(extractorConfig);

// There seems to be no way to suppress the following annoying output: "Analysis will use the
// bundled TypeScript version x.x.x. The target project appears to use TypeScript x.x.x which is
// newer than the bundled compiler engine; consider upgrading API Extractor."

if (!extractorResult.succeeded) {
fatalError("API Extractor failed.");
}
function scrubInternalExports() {
$sq`npx api-extractor run`; // `api-extractor` is noisy and we only care if it fails.
}

0 comments on commit acca18f

Please sign in to comment.