From 55117ea60705c12b240778e2753c73aea2bd002c Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Tue, 8 Aug 2017 19:03:56 -0700 Subject: [PATCH] Remove typed option loading Summary: The API to load custom config types is no longer needed, and can be removed Reviewed By: cpojer Differential Revision: D5579721 fbshipit-source-id: f8bc117491134c1177cf17a84360524432579ab9 --- local-cli/util/Config.js | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/local-cli/util/Config.js b/local-cli/util/Config.js index 8c1b7cff1..227d394e5 100644 --- a/local-cli/util/Config.js +++ b/local-cli/util/Config.js @@ -195,51 +195,30 @@ const Config = { }: ConfigT), find(startDir: string): ConfigT { - return Config.findCustom(startDir, Config.DEFAULTS); - }, - - /** - * This allows a callsite to grab a config that may have custom fields or - * a different version of the config. In that case the defaults have to be - * specified explicitely. - */ - findCustom(startDir: string, defaults: TConfig): TConfig { - return Config.findWithPathCustom(startDir, defaults).config; + return this.findWithPath(startDir).config; }, findWithPath(startDir: string): {config: ConfigT, projectPath: string} { - return Config.findWithPathCustom(startDir, Config.DEFAULTS); - }, - - findWithPathCustom(startDir: string, defaults: TConfig): {config: TConfig, projectPath: string} { const configPath = findConfigPath(startDir); invariant( configPath, `Can't find "${RN_CLI_CONFIG}" file in any parent folder of "${startDir}"`, ); const projectPath = path.dirname(configPath); - return {config: Config.loadFileCustom(configPath, defaults), projectPath}; + return {config: this.loadFile(configPath, startDir), projectPath}; }, findOptional(startDir: string): ConfigT { - return Config.findOptionalCustom(startDir, Config.DEFAULTS); - }, - - findOptionalCustom(startDir: string, defaults: TConfig): TConfig { const configPath = findConfigPath(startDir); return configPath - ? Config.loadFileCustom(configPath, defaults) - : {...defaults}; + ? this.loadFile(configPath, startDir) + : {...Config.DEFAULTS}; }, loadFile(pathToConfig: string): ConfigT { - return Config.loadFileCustom(pathToConfig, Config.DEFAULTS); - }, - - loadFileCustom(pathToConfig: string, defaults: TConfig): TConfig { - // $FlowFixMe: necessary dynamic require + //$FlowFixMe: necessary dynamic require const config: {} = require(pathToConfig); - return {...defaults, ...config}; + return {...Config.DEFAULTS, ...config}; }, };