forked from mozilla/sphinx-js
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split call_typedoc into main.ts and cli.ts. NFC
This moves most of the logic from call_typedoc.ts into a separate file called `cli.ts` which avoids some of the io like `process.exit()` and serializing json / writing to a file. Intended to help with testing.
- Loading branch information
Showing
4 changed files
with
43 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { writeFile } from "fs/promises"; | ||
import { ExitError, run } from "./cli.ts"; | ||
|
||
async function main() { | ||
const start = Date.now(); | ||
const args = process.argv.slice(2); | ||
let app, result; | ||
try { | ||
[app, result] = await run(args); | ||
} catch(e) { | ||
if (e instanceof ExitError) { | ||
return e.code; | ||
} | ||
throw e; | ||
} | ||
const space = app.options.getValue("pretty") ? "\t" : ""; | ||
const res = JSON.stringify([result, app.extraData], null, space); | ||
const json = app.options.getValue("json"); | ||
await writeFile(json, res); | ||
app.logger.info(`JSON written to ${json}`); | ||
app.logger.verbose(`JSON rendering took ${Date.now() - start}ms`); | ||
return 0; | ||
} | ||
|
||
process.exit(await main()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,7 +108,7 @@ def test_global_install(tmp_path_factory, monkeypatch): | |
"[email protected]", | ||
"--import", | ||
dir / "registerImportHook.mjs", | ||
dir / "call_typedoc.ts", | ||
dir / "main.ts", | ||
"--version", | ||
], | ||
capture_output=True, | ||
|