Skip to content

Commit 3e609d9

Browse files
pat841aciccarello
authored andcommitted
fix(options): Increase argument options reader discover event priority (#610)
Previously the arguments reader would run after both the tsconfig and typedoc readers. However, both of those readers rely on event data such as "-options" that is parsed by the arguments reader which leads to issues when trying to point to a given config using a CLI argument.
1 parent e60ef6e commit 3e609d9

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

src/lib/application.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class Application extends ChildableComponent<Application, AbstractCompone
122122
}
123123

124124
this.plugins.load();
125-
return this.options.read(options, OptionsReadMode.Fetch);
125+
return this.options.read(this.options.getRawValues(), OptionsReadMode.Fetch);
126126
}
127127

128128
/**

src/lib/utils/options/readers/arguments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class ArgumentsReader extends OptionsComponent {
5858
files.push(arg);
5959
}
6060
}
61-
if (files) {
61+
if (files && files.length > 0) {
6262
event.inputFiles = files;
6363
}
6464
}

src/lib/utils/options/readers/tsconfig.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as _ from 'lodash';
44
import * as ts from 'typescript';
55

66
import { Component, Option } from '../../component';
7-
import { OptionsComponent, DiscoverEvent } from '../options';
7+
import { OptionsComponent, OptionsReadMode, DiscoverEvent } from '../options';
88
import { ParameterType, ParameterHint } from '../declaration';
99
import { TypeScriptSource } from '../sources/typescript';
1010

@@ -35,6 +35,11 @@ export class TSConfigReader extends OptionsComponent {
3535
}
3636

3737
onDiscover(event: DiscoverEvent) {
38+
// Do nothing until were fetching options
39+
if (event.mode !== OptionsReadMode.Fetch) {
40+
return;
41+
}
42+
3843
if (TSConfigReader.OPTIONS_KEY in event.data) {
3944
this.load(event, Path.resolve(event.data[TSConfigReader.OPTIONS_KEY]));
4045
} else if (TSConfigReader.PROJECT_KEY in event.data) {

src/lib/utils/options/readers/typedoc.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as FS from 'fs';
33
import * as _ from 'lodash';
44

55
import { Component, Option } from '../../component';
6-
import { OptionsComponent, DiscoverEvent } from '../options';
6+
import { OptionsComponent, OptionsReadMode, DiscoverEvent } from '../options';
77
import { ParameterType, ParameterHint } from '../declaration';
88

99
@Component({name: 'options:typedoc'})
@@ -26,6 +26,11 @@ export class TypedocReader extends OptionsComponent {
2626
}
2727

2828
onDiscover(event: DiscoverEvent) {
29+
// Do nothing until were fetching options
30+
if (event.mode !== OptionsReadMode.Fetch) {
31+
return;
32+
}
33+
2934
if (TypedocReader.OPTIONS_KEY in event.data) {
3035
this.load(event, Path.resolve(event.data[TypedocReader.OPTIONS_KEY]));
3136
} else if (this.application.isCLI) {

0 commit comments

Comments
 (0)