Skip to content

Commit

Permalink
Improve expo detection in monorepos
Browse files Browse the repository at this point in the history
  • Loading branch information
zoontek committed Aug 25, 2024
1 parent 88c6041 commit fbb8f02
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ PODS:
- React-logger (= 0.74.3)
- React-perflogger (= 0.74.3)
- React-utils (= 0.74.3)
- RNBootSplash (6.1.1):
- RNBootSplash (6.1.2):
- React-Core
- SocketRocket (0.7.0)
- Yoga (0.0.0)
Expand Down Expand Up @@ -1399,7 +1399,7 @@ SPEC CHECKSUMS:
React-runtimescheduler: 0c80752bceb80924cb8a4babc2a8e3ed70d41e87
React-utils: a06061b3887c702235d2dac92dacbd93e1ea079e
ReactCommon: f00e436b3925a7ae44dfa294b43ef360fbd8ccc4
RNBootSplash: 5951974a5271183d06d3279bd4b9d7d093f4e2fc
RNBootSplash: 4cb5ac8f6eeb5c30b0d2d3a44b8f40f80bcf8b45
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: 04f1db30bb810187397fa4c37dd1868a27af229c

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-bootsplash",
"version": "6.1.1",
"version": "6.1.2",
"license": "MIT",
"description": "Display a bootsplash on your app starts. Hide it when you want.",
"author": "Mathieu Acthernoene <[email protected]>",
Expand Down
43 changes: 30 additions & 13 deletions src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,40 @@ export const hfs = {
},
};

export const getExpoConfig = (projectRoot: string): { isExpo: boolean } => {
try {
const pkg = hfs.json(
path.resolve(projectRoot, "node_modules", "expo", "package.json"),
) as { version?: string };
// Adapted from https://github.com/square/find-yarn-workspace-root
export const getExpoConfig = (from: string): { isExpo: boolean } => {
let previous: string | undefined;
let current = path.normalize(from);

do {
const pkgPath = path.resolve(
current,
"node_modules",
"expo",
"package.json",
);

const version = pkg.version;
if (fs.existsSync(pkgPath)) {
try {
const pkg = hfs.json(pkgPath) as { version?: string };
const version = pkg.version;

if (version == null || semver.lt(version, "51.0.20")) {
log.error("Requires Expo 51.0.20 (or higher)");
process.exit(1);
}

if (version == null || semver.lt(version, "51.0.20")) {
log.error("Requires Expo 51.0.20 (or higher)");
process.exit(1);
return { isExpo: true };
} catch {
return { isExpo: false };
}
}

return { isExpo: true };
} catch {
return { isExpo: false };
}
previous = current;
current = path.dirname(current);
} while (current !== previous);

return { isExpo: false };
};

export const writeJson = (filePath: string, content: object) => {
Expand Down

0 comments on commit fbb8f02

Please sign in to comment.