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

Function findProjectRoot

Example/e2etest/e2e/globalTeardown.ts:7–29  ·  view source on GitHub ↗
(...startDirs: string[])

Source from the content-addressed store, hash-verified

5);
6
7function findProjectRoot(...startDirs: string[]) {
8 for (const startDir of startDirs) {
9 let currentDir = path.resolve(startDir);
10 while (true) {
11 const hasMarkers =
12 fs.existsSync(path.join(currentDir, 'package.json')) &&
13 fs.existsSync(path.join(currentDir, 'scripts/run-prepare-local-update-artifacts.js')) &&
14 fs.existsSync(path.join(currentDir, 'scripts/local-e2e-server.ts'));
15
16 if (hasMarkers) {
17 return currentDir;
18 }
19
20 const parentDir = path.dirname(currentDir);
21 if (parentDir === currentDir) {
22 break;
23 }
24 currentDir = parentDir;
25 }
26 }
27
28 throw new Error('Unable to resolve the e2etest project root.');
29}
30
31const projectRoot = findProjectRoot(process.cwd(), __dirname);
32const pidFile = path.join(projectRoot, '.e2e-artifacts/.server.pid');

Callers 1

globalTeardown.tsFile · 0.70

Calls 1

resolveMethod · 0.80

Tested by

no test coverage detected