fix: detect core version before including inspector_modules on android (#10520)

This commit is contained in:
Igor Randjelovic
2024-04-16 14:20:14 +02:00
committed by GitHub
parent e234ca6052
commit ccee8e8166
12 changed files with 70 additions and 58 deletions

View File

@ -47,3 +47,23 @@ export function getDependencyPath(dependencyName: string): string | null {
return null;
}
}
/**
* Utility to get the version of a dependency.
*
* @param dependencyName
* @returns string | null - version of the dependency or null if not found
*/
export function getDependencyVersion(dependencyName: string): string | null {
const dependencyPath = getDependencyPath(dependencyName);
if (!dependencyPath) {
return null;
}
try {
return require(`${dependencyPath}/package.json`).version;
} catch (err) {
// ignore
}
return null;
}