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
This commit is contained in:
David Aurelio 2017-08-08 19:03:56 -07:00 коммит произвёл Facebook Github Bot
Родитель bb7a78c446
Коммит 55117ea607
1 изменённых файлов: 6 добавлений и 27 удалений

Просмотреть файл

@ -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<TConfig: {}>(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<TConfig: {}>(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<TConfig: {}>(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<TConfig: {}>(pathToConfig: string, defaults: TConfig): TConfig {
// $FlowFixMe: necessary dynamic require
//$FlowFixMe: necessary dynamic require
const config: {} = require(pathToConfig);
return {...defaults, ...config};
return {...Config.DEFAULTS, ...config};
},
};