mirror of
https://github.com/status-im/react-native.git
synced 2025-02-25 15:45:32 +00:00
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
This commit is contained in:
parent
bb7a78c446
commit
55117ea607
@ -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};
|
||||
},
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user