message: Optimize tsconfig.json file finding
diff: @@ -40,23 +40,32 @@ export class TSConfigReader extends OptionsComponent {
  return;
  }
  + let file: string;
  +
  if (TSConfigReader.OPTIONS_KEY in event.data) {
  - this.load(event, Path.resolve(event.data[TSConfigReader.OPTIONS_KEY]));
  + const tsconfig = event.data[TSConfigReader.OPTIONS_KEY];
  +
  + file = /tsconfig\.json$/.test(tsconfig)
  + ? Path.resolve(tsconfig)
  + : ts.findConfigFile(tsconfig, ts.sys.fileExists);
  +
  + if (!file || !FS.existsSync(file)) {
  + event.addError('The tsconfig file %s does not exist.', file);
  + return;
  + }
  } else if (TSConfigReader.PROJECT_KEY in event.data) {
  // The `project` option may be a directory or file, so use TS to find it
  - let file: string = ts.findConfigFile(event.data[TSConfigReader.PROJECT_KEY], ts.sys.fileExists);
  - // If file is undefined, we found no file to load.
  - if (file) {
  - this.load(event, file);
  - }
  + file = ts.findConfigFile(event.data[TSConfigReader.PROJECT_KEY], ts.sys.fileExists);
  } else if (this.application.isCLI) {
  - let file: string = ts.findConfigFile('.', ts.sys.fileExists);
  + // No file or directory has been specified so find the file in the root of the project
  + file = ts.findConfigFile('.', ts.sys.fileExists);
  + }
  +
  // If file is undefined, we found no file to load.
  if (file) {
  this.load(event, file);
  }
  }
  - }
  /**
  * Load the specified tsconfig file.
  @@ -65,11 +74,6 @@ export class TSConfigReader extends OptionsComponent {
  * @param fileName The absolute path and file name of the tsconfig file.
  */
  load(event: DiscoverEvent, fileName: string) {
  - if (!FS.existsSync(fileName)) {
  - event.addError('The tsconfig file %s does not exist.', fileName);
  - return;
  - }
  -
  const { config } = ts.readConfigFile(fileName, ts.sys.readFile);
  if (config === undefined) {
  event.addError('The tsconfig file %s does not contain valid JSON.', fileName);
  