Skip to content

Commit

Permalink
fix(options): Increase argument options reader discover event priority (
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
pat841 authored and aciccarello committed Mar 5, 2018
1 parent e60ef6e commit 3e609d9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/lib/application.ts
Expand Up @@ -122,7 +122,7 @@ export class Application extends ChildableComponent<Application, AbstractCompone
}

this.plugins.load();
return this.options.read(options, OptionsReadMode.Fetch);
return this.options.read(this.options.getRawValues(), OptionsReadMode.Fetch);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils/options/readers/arguments.ts
Expand Up @@ -58,7 +58,7 @@ export class ArgumentsReader extends OptionsComponent {
files.push(arg);
}
}
if (files) {
if (files && files.length > 0) {
event.inputFiles = files;
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/lib/utils/options/readers/tsconfig.ts
Expand Up @@ -4,7 +4,7 @@ import * as _ from 'lodash';
import * as ts from 'typescript';

import { Component, Option } from '../../component';
import { OptionsComponent, DiscoverEvent } from '../options';
import { OptionsComponent, OptionsReadMode, DiscoverEvent } from '../options';
import { ParameterType, ParameterHint } from '../declaration';
import { TypeScriptSource } from '../sources/typescript';

Expand Down Expand Up @@ -35,6 +35,11 @@ export class TSConfigReader extends OptionsComponent {
}

onDiscover(event: DiscoverEvent) {
// Do nothing until were fetching options
if (event.mode !== OptionsReadMode.Fetch) {
return;
}

if (TSConfigReader.OPTIONS_KEY in event.data) {
this.load(event, Path.resolve(event.data[TSConfigReader.OPTIONS_KEY]));
} else if (TSConfigReader.PROJECT_KEY in event.data) {
Expand Down
7 changes: 6 additions & 1 deletion src/lib/utils/options/readers/typedoc.ts
Expand Up @@ -3,7 +3,7 @@ import * as FS from 'fs';
import * as _ from 'lodash';

import { Component, Option } from '../../component';
import { OptionsComponent, DiscoverEvent } from '../options';
import { OptionsComponent, OptionsReadMode, DiscoverEvent } from '../options';
import { ParameterType, ParameterHint } from '../declaration';

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

onDiscover(event: DiscoverEvent) {
// Do nothing until were fetching options
if (event.mode !== OptionsReadMode.Fetch) {
return;
}

if (TypedocReader.OPTIONS_KEY in event.data) {
this.load(event, Path.resolve(event.data[TypedocReader.OPTIONS_KEY]));
} else if (this.application.isCLI) {
Expand Down

0 comments on commit 3e609d9

Please sign in to comment.