MCPcopy Create free account
hub / github.com/reactnativecn/react-native-update / findProjectRoot

Function findProjectRoot

Example/e2etest/e2e/globalSetup.ts:13–40  ·  view source on GitHub ↗
(...startDirs: string[])

Source from the content-addressed store, hash-verified

11const detoxGlobalSetup: () => Promise<void> = require('detox/runners/jest/globalSetup.js');
12
13function findProjectRoot(...startDirs: string[]) {
14 for (const startDir of startDirs) {
15 let currentDir = path.resolve(startDir);
16 while (true) {
17 const hasMarkers =
18 fs.existsSync(path.join(currentDir, 'package.json')) &&
19 fs.existsSync(
20 path.join(
21 currentDir,
22 'scripts/run-prepare-local-update-artifacts.js',
23 ),
24 ) &&
25 fs.existsSync(path.join(currentDir, 'scripts/local-e2e-server.ts'));
26
27 if (hasMarkers) {
28 return currentDir;
29 }
30
31 const parentDir = path.dirname(currentDir);
32 if (parentDir === currentDir) {
33 break;
34 }
35 currentDir = parentDir;
36 }
37 }
38
39 throw new Error('Unable to resolve the e2etest project root.');
40}
41
42const projectRoot = findProjectRoot(process.cwd(), __dirname);
43const packageJson = JSON.parse(

Callers 1

globalSetup.tsFile · 0.70

Calls 1

resolveMethod · 0.80

Tested by

no test coverage detected