From 3e609d99ea1a2416a02f1edc6c503eee1271346d Mon Sep 17 00:00:00 2001 From: Pat Herlihy Date: Mon, 5 Mar 2018 01:22:31 -0500 Subject: [PATCH] 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. --- src/lib/application.ts | 2 +- src/lib/utils/options/readers/arguments.ts | 2 +- src/lib/utils/options/readers/tsconfig.ts | 7 ++++++- src/lib/utils/options/readers/typedoc.ts | 7 ++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/lib/application.ts b/src/lib/application.ts index 30a5e3b0f..ba72dff84 100644 --- a/src/lib/application.ts +++ b/src/lib/application.ts @@ -122,7 +122,7 @@ export class Application extends ChildableComponent 0) { event.inputFiles = files; } } diff --git a/src/lib/utils/options/readers/tsconfig.ts b/src/lib/utils/options/readers/tsconfig.ts index f1aef133b..d0430bb9e 100644 --- a/src/lib/utils/options/readers/tsconfig.ts +++ b/src/lib/utils/options/readers/tsconfig.ts @@ -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'; @@ -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) { diff --git a/src/lib/utils/options/readers/typedoc.ts b/src/lib/utils/options/readers/typedoc.ts index ad5a44f04..a03e8df11 100644 --- a/src/lib/utils/options/readers/typedoc.ts +++ b/src/lib/utils/options/readers/typedoc.ts @@ -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'}) @@ -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) {