MCPcopy Index your code
hub / github.com/react-native-community/cli / findProjectRoot

Function findProjectRoot

packages/cli-tools/src/findProjectRoot.ts:8–25  ·  view source on GitHub ↗
(cwd = process.cwd())

Source from the content-addressed store, hash-verified

6 * Finds project root by looking for a closest `package.json`.
7 */
8export default function findProjectRoot(cwd = process.cwd()): string {
9 const packageLocation = findUp.sync('package.json', {cwd});
10 /**
11 * It is possible that `package.json` doesn't exist
12 * in the tree. In that case, we want to throw an error.
13 *
14 * When executing via `npx`, this will never happen as `npm`
15 * requires that file to be present in order to run.
16 */
17 if (!packageLocation) {
18 throw new CLIError(`
19 We couldn't find a package.json in your project.
20 Are you sure you are running it inside a React Native project?
21 `);
22 }
23
24 return path.dirname(packageLocation);
25}

Callers 7

loadConfigFunction · 0.90
loadConfigAsyncFunction · 0.90
ruby.tsFile · 0.90
gradle.tsFile · 0.90
xcodeEnv.tsFile · 0.90
getBuildToolsVersionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected