Safer workaround for Android SDK detection with Java 9/10
Summary: Safer workaround for Android SDK detection with Java 9/10 Reviewed By: mweststrate Differential Revision: D19158381 fbshipit-source-id: 8c4ce456543712204423f14abe8a1840308c8bf9
This commit is contained in:
committed by
Facebook Github Bot
parent
db721e94a6
commit
b716b50729
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "flipper-doctor",
|
||||
"version": "0.2.3",
|
||||
"version": "0.2.4",
|
||||
"description": "Utility for checking for issues with a flipper installation",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
|
||||
@@ -31,14 +31,39 @@ export type EnvironmentInfo = {
|
||||
};
|
||||
};
|
||||
|
||||
export async function getEnvInfo(): Promise<EnvironmentInfo> {
|
||||
async function retrieveAndParseEnvInfo(): Promise<any> {
|
||||
return JSON.parse(
|
||||
await run(
|
||||
{
|
||||
SDKs: ['iOS SDK', 'Android SDK'],
|
||||
IDEs: ['Xcode'],
|
||||
Languages: ['Java'],
|
||||
},
|
||||
{json: true, showNotFound: true},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Temporary workaround for https://github.com/facebook/flipper/issues/667 until it properly fixed in 'envinfo'.
|
||||
async function workaroundForNewerJavaVersions(envInfo: any) {
|
||||
try {
|
||||
if (envInfo.Languages.Java && envInfo.Languages.Java.version) {
|
||||
const [majorVersion] = envInfo.Languages.Java.version
|
||||
.split('.')
|
||||
.slice(0, 1)
|
||||
.map((x: string) => parseInt(x, 10));
|
||||
if (8 < majorVersion && majorVersion < 11) {
|
||||
process.env.JAVA_OPTS =
|
||||
'-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee';
|
||||
return await retrieveAndParseEnvInfo();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
return envInfo;
|
||||
}
|
||||
|
||||
export async function getEnvInfo(): Promise<EnvironmentInfo> {
|
||||
return workaroundForNewerJavaVersions(await retrieveAndParseEnvInfo());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user