Skip to content

Commit

Permalink
refactor: access 'pretty' option directly from generateJson()
Browse files Browse the repository at this point in the history
  • Loading branch information
cAttte authored and Gerrit0 committed Apr 10, 2021
1 parent d5930e0 commit 0524305
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
6 changes: 2 additions & 4 deletions bin/typedoc
Expand Up @@ -66,8 +66,7 @@ async function run(app) {
}
const json = app.options.getValue("json");
if (json) {
const pretty = app.options.getValue("pretty");
await app.generateJson(project, json, pretty);
await app.generateJson(project, json);
}

if (!out && !json) {
Expand All @@ -88,8 +87,7 @@ async function run(app) {
}
const json = app.options.getValue("json");
if (json) {
const pretty = app.options.getValue("pretty");
await app.generateJson(project, json, pretty);
await app.generateJson(project, json);
}

if (!out && !json) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/rebuild_specs.js
Expand Up @@ -107,7 +107,7 @@ async function rebuildRendererTest() {
app.options.setValue("entryPoints", app.expandInputFiles([src]));
const project = app.convert();
await app.generateDocs(project, out);
await app.generateJson(project, path.join(out, "specs.json"), true);
await app.generateJson(project, path.join(out, "specs.json"));

/**
* Avoiding sync methods here is... difficult.
Expand Down
6 changes: 2 additions & 4 deletions src/lib/application.ts
Expand Up @@ -388,13 +388,11 @@ export class Application extends ChildableComponent<
* Run the converter for the given set of files and write the reflections to a json file.
*
* @param out The path and file name of the target file.
* @param format Whether the JSON data should be formatted with tabs.
* @returns Whether the JSON file could be written successfully.
*/
public async generateJson(
project: ProjectReflection,
out: string,
format = true
out: string
): Promise<void> {
out = Path.resolve(out);
const eventData = {
Expand All @@ -406,7 +404,7 @@ export class Application extends ChildableComponent<
end: eventData,
});

const space = format ? "\t" : "";
const space = this.application.options.getValue("pretty") ? "\t" : "";
await FS.promises.writeFile(out, JSON.stringify(ser, null, space));
this.logger.success("JSON written to %s", out);
}
Expand Down

0 comments on commit 0524305

Please sign in to comment.