diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 861e88be..fe809f96 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -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) @@ -1399,7 +1399,7 @@ SPEC CHECKSUMS: React-runtimescheduler: 0c80752bceb80924cb8a4babc2a8e3ed70d41e87 React-utils: a06061b3887c702235d2dac92dacbd93e1ea079e ReactCommon: f00e436b3925a7ae44dfa294b43ef360fbd8ccc4 - RNBootSplash: 5951974a5271183d06d3279bd4b9d7d093f4e2fc + RNBootSplash: 4cb5ac8f6eeb5c30b0d2d3a44b8f40f80bcf8b45 SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: 04f1db30bb810187397fa4c37dd1868a27af229c diff --git a/package.json b/package.json index e357c1fd..e244560a 100644 --- a/package.json +++ b/package.json @@ -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 ", diff --git a/src/generate.ts b/src/generate.ts index c42b8d13..8ab8b4c0 100644 --- a/src/generate.ts +++ b/src/generate.ts @@ -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) => {