diff --git a/local-cli/util/Config.js b/local-cli/util/Config.js index 3609dec7f4bb2f..b799c97fcf1ffc 100644 --- a/local-cli/util/Config.js +++ b/local-cli/util/Config.js @@ -22,7 +22,7 @@ const {loadConfig} = require('metro-config'); */ import type {ConfigT} from 'metro-config/src/configTypes.flow'; -function getProjectPath() { +function getProjectRoot() { if ( __dirname.match(/node_modules[\/\\]react-native[\/\\]local-cli[\/\\]util$/) ) { @@ -51,12 +51,12 @@ const resolveSymlinksForRoots = roots => [...roots], ); -const getProjectRoots = () => { +const getWatchFolders = () => { const root = process.env.REACT_NATIVE_APP_ROOT; if (root) { return resolveSymlinksForRoots([path.resolve(root)]); } - return resolveSymlinksForRoots([getProjectPath()]); + return []; }; const getBlacklistRE = () => { @@ -83,17 +83,15 @@ const Config = { ], getPolyfills, }, - - watchFolders: [getProjectPath(), ...getProjectRoots()], + watchFolders: getWatchFolders(), transformModulePath: require.resolve('metro/src/reactNativeTransformer'), }, - getProjectPath, - getProjectRoots, - async load(configFile: ?string): Promise { + const argv = {cwd: getProjectRoot()}; + return await loadConfig( - configFile ? {config: configFile} : {}, + configFile ? {...argv, config: configFile} : argv, this.DEFAULT, ); },