Skip to content

Commit 13ccc02

Browse files
artenticaaciccarello
authored andcommitted
feat(cli): if no out or json cmd, put out to ./docs (#970)
1 parent ace91a3 commit 13ccc02

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

src/lib/cli.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,41 @@ import { ParameterHint, ParameterType } from './utils/options/declaration';
77
import { getOptionsHelp } from './utils/options/help';
88

99
export const enum ExitCode {
10-
OptionError = 1,
10+
OptionError = 1,
1111
NoInputFiles = 2,
12-
NoOutput = 3,
12+
NoOutput = 3,
1313
CompileError = 4,
14-
OutputError = 5
14+
OutputError = 5
1515
}
1616

1717
export class CliApplication extends Application {
1818
@Option({
19-
name: 'out',
20-
help: 'Specifies the location the documentation should be written to.',
21-
hint: ParameterHint.Directory
19+
name: 'out',
20+
help: 'Specifies the location the documentation should be written to.',
21+
hint: ParameterHint.Directory
2222
})
2323
out!: string;
2424

2525
@Option({
26-
name: 'json',
27-
help: 'Specifies the location and file name a json file describing the project is written to.',
28-
hint: ParameterHint.File
26+
name: 'json',
27+
help: 'Specifies the location and file name a json file describing the project is written to.',
28+
hint: ParameterHint.File
2929
})
3030
json!: string;
3131

3232
@Option({
33-
name: 'version',
33+
name: 'version',
3434
short: 'v',
35-
help: 'Print the TypeDoc\'s version.',
36-
type: ParameterType.Boolean
35+
help: 'Print the TypeDoc\'s version.',
36+
type: ParameterType.Boolean
3737
})
3838
version!: boolean;
3939

4040
@Option({
41-
name: 'help',
41+
name: 'help',
4242
short: 'h',
43-
help: 'Print this message.',
44-
type: ParameterType.Boolean
43+
help: 'Print this message.',
44+
type: ParameterType.Boolean
4545
})
4646
help!: boolean;
4747

@@ -61,9 +61,6 @@ export class CliApplication extends Application {
6161
} else if (result.inputFiles.length === 0) {
6262
typescript.sys.write(getOptionsHelp(this.options));
6363
process.exit(ExitCode.NoInputFiles);
64-
} else if (!this.out && !this.json) {
65-
this.logger.error("You must either specify the 'out' or 'json' option.");
66-
process.exit(ExitCode.NoOutput);
6764
} else {
6865
const src = this.expandInputFiles(result.inputFiles);
6966
const project = this.convert(src);
@@ -74,6 +71,11 @@ export class CliApplication extends Application {
7471
if (this.json) {
7572
this.generateJson(project, this.json);
7673
}
74+
if (!this.out && !this.json) {
75+
this.logger.log("No 'out' or 'json' option has been set");
76+
this.logger.log("The './docs' directory has be set as the output location by default");
77+
this.generateDocs(project, './docs');
78+
}
7779
if (this.logger.hasErrors()) {
7880
process.exit(ExitCode.OutputError);
7981
}

0 commit comments

Comments
 (0)