Skip to content

Commit f59d79c

Browse files
mike-marcaccifacebook-github-bot
authored andcommitted
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: #20992 Differential Revision: D13422928 Pulled By: hramos fbshipit-source-id: 72dd07e82a366439f663508b07c1de5ca59b9dbf
1 parent 0314fca commit f59d79c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

react-native-git-upgrade/cliEntry.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,18 @@ function readPackageFiles(useYarn) {
114114
'package.json',
115115
);
116116
const pakPath = path.resolve(process.cwd(), 'package.json');
117+
const appPath = path.resolve(process.cwd(), 'app.json');
118+
let app = null;
119+
try {
120+
app = parseJsonFile(appPath);
121+
} catch (err) {
122+
log.warn('Unable to parse app.json', err.message);
123+
}
117124
return {
118125
reactNativeNodeModulesPak: parseJsonFile(reactNativeNodeModulesPakPath),
119126
reactNodeModulesPak: parseJsonFile(reactNodeModulesPakPath),
120127
pak: parseJsonFile(pakPath),
128+
app: app,
121129
};
122130
}
123131

@@ -305,8 +313,9 @@ async function run(requestedVersion, cliArgs) {
305313
reactNativeNodeModulesPak,
306314
reactNodeModulesPak,
307315
pak,
316+
app,
308317
} = readPackageFiles(useYarn);
309-
const appName = pak.name;
318+
const appName = (app && app.name) || pak.name;
310319
const currentVersion = reactNativeNodeModulesPak.version;
311320
const currentReactVersion = reactNodeModulesPak.version;
312321
const declaredVersion = pak.dependencies['react-native'];

0 commit comments

Comments
 (0)