react-native-bootsplash 6.1.1 → 6.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/generate.ts CHANGED
@@ -185,23 +185,40 @@ export const hfs = {
185
185
  },
186
186
  };
187
187
 
188
- export const getExpoConfig = (projectRoot: string): { isExpo: boolean } => {
189
- try {
190
- const pkg = hfs.json(
191
- path.resolve(projectRoot, "node_modules", "expo", "package.json"),
192
- ) as { version?: string };
188
+ // Adapted from https://github.com/square/find-yarn-workspace-root
189
+ export const getExpoConfig = (from: string): { isExpo: boolean } => {
190
+ let previous: string | undefined;
191
+ let current = path.normalize(from);
192
+
193
+ do {
194
+ const pkgPath = path.resolve(
195
+ current,
196
+ "node_modules",
197
+ "expo",
198
+ "package.json",
199
+ );
193
200
 
194
- const version = pkg.version;
201
+ if (fs.existsSync(pkgPath)) {
202
+ try {
203
+ const pkg = hfs.json(pkgPath) as { version?: string };
204
+ const version = pkg.version;
205
+
206
+ if (version == null || semver.lt(version, "51.0.20")) {
207
+ log.error("Requires Expo 51.0.20 (or higher)");
208
+ process.exit(1);
209
+ }
195
210
 
196
- if (version == null || semver.lt(version, "51.0.20")) {
197
- log.error("Requires Expo 51.0.20 (or higher)");
198
- process.exit(1);
211
+ return { isExpo: true };
212
+ } catch {
213
+ return { isExpo: false };
214
+ }
199
215
  }
200
216
 
201
- return { isExpo: true };
202
- } catch {
203
- return { isExpo: false };
204
- }
217
+ previous = current;
218
+ current = path.dirname(current);
219
+ } while (current !== previous);
220
+
221
+ return { isExpo: false };
205
222
  };
206
223
 
207
224
  export const writeJson = (filePath: string, content: object) => {
@@ -612,9 +629,8 @@ export const generate = async ({
612
629
  darkBrand?: string;
613
630
  }) => {
614
631
  const isExpo =
615
- projectType === "detect" || projectType === "expo"
616
- ? getExpoConfig(workingPath).isExpo
617
- : false;
632
+ projectType === "expo" ||
633
+ (projectType === "detect" && getExpoConfig(workingPath).isExpo);
618
634
 
619
635
  if (semver.lt(process.versions.node, "18.0.0")) {
620
636
  log.error("Requires Node 18 (or higher)");