MCPcopy Create free account
hub / github.com/firebase/firebase-tools / detectProjectRoot

Function detectProjectRoot

src/detectProjectRoot.ts:5–30  ·  view source on GitHub ↗
(options: {
  cwd?: string;
  configPath?: string;
})

Source from the content-addressed store, hash-verified

3import { dirname, resolve } from "path";
4
5export function detectProjectRoot(options: {
6 cwd?: string;
7 configPath?: string;
8}): string | undefined {
9 let projectRootDir = options.cwd || process.cwd();
10 if (options.configPath) {
11 const fullPath = resolve(projectRootDir, options.configPath);
12 if (!fileExistsSync(fullPath)) {
13 throw new FirebaseError(`Could not load config file ${options.configPath}.`, {
14 exit: 1,
15 status: 404,
16 });
17 }
18
19 return dirname(fullPath);
20 }
21
22 while (!fileExistsSync(resolve(projectRootDir, "./firebase.json"))) {
23 const parentDir = dirname(projectRootDir);
24 if (parentDir === projectRootDir) {
25 return undefined;
26 }
27 projectRootDir = parentDir;
28 }
29 return projectRootDir;
30}

Callers 7

constructorMethod · 0.90
loadMethod · 0.90
resolveProjectPathFunction · 0.90
prepareMethod · 0.90
loadRCFunction · 0.90
runDeploysFunction · 0.90
startServerFunction · 0.90

Calls 2

fileExistsSyncFunction · 0.90
resolveFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…