MCPcopy
hub / github.com/activepieces/activepieces / findRepoRoot

Function findRepoRoot

packages/cli/src/lib/utils/workspace-utils.ts:6–22  ·  view source on GitHub ↗
(startDir: string)

Source from the content-addressed store, hash-verified

4// Walk up from a piece folder to the monorepo root (the package.json that declares
5// `workspaces`). Lets bundling run from any cwd — e.g. a per-package turbo task.
6export function findRepoRoot(startDir: string): string {
7 let dir = startDir
8 while (true) {
9 const pkgPath = join(dir, 'package.json')
10 if (existsSync(pkgPath)) {
11 const pkg = JSON.parse(readFileSync(pkgPath).toString())
12 if (Array.isArray(pkg.workspaces)) {
13 return dir
14 }
15 }
16 const parent = dirname(dir)
17 if (parent === dir) {
18 throw new Error(`[findRepoRoot] no workspace root found above ${startDir}`)
19 }
20 dir = parent
21 }
22}
23
24export function buildWorkspaceVersionMap(rootDir: string): Map<string, string> {
25 const versionMap = new Map<string, string>()

Callers 1

Calls 2

joinFunction · 0.85
toStringMethod · 0.45

Tested by

no test coverage detected