Fix #20991 - use name from app.json if available (#20992)

Summary:
Fix #20991 - use name from `app.json` if available, instead of using `package.json`.
Pull Request resolved: https://github.com/facebook/react-native/pull/20992

Differential Revision: D13422928

Pulled By: hramos

fbshipit-source-id: 72dd07e82a366439f663508b07c1de5ca59b9dbf
This commit is contained in:
Mike Marcacci
2018-12-11 17:18:45 -08:00
committed by Facebook Github Bot
parent 0314fca63a
commit f59d79caba

View File

@@ -114,10 +114,18 @@ function readPackageFiles(useYarn) {
'package.json',
);
const pakPath = path.resolve(process.cwd(), 'package.json');
const appPath = path.resolve(process.cwd(), 'app.json');
let app = null;
try {
app = parseJsonFile(appPath);
} catch (err) {
log.warn('Unable to parse app.json', err.message);
}
return {
reactNativeNodeModulesPak: parseJsonFile(reactNativeNodeModulesPakPath),
reactNodeModulesPak: parseJsonFile(reactNodeModulesPakPath),
pak: parseJsonFile(pakPath),
app: app,
};
}
@@ -305,8 +313,9 @@ async function run(requestedVersion, cliArgs) {
reactNativeNodeModulesPak,
reactNodeModulesPak,
pak,
app,
} = readPackageFiles(useYarn);
const appName = pak.name;
const appName = (app && app.name) || pak.name;
const currentVersion = reactNativeNodeModulesPak.version;
const currentReactVersion = reactNodeModulesPak.version;
const declaredVersion = pak.dependencies['react-native'];