MCPcopy Create free account
hub / github.com/agent-tower/core / findFiles

Function findFiles

packages/server/scripts/postinstall.js:37–58  ·  view source on GitHub ↗

* 递归查找匹配的文件

(dir, pattern, results = [], depth = 0, maxDepth = 10)

Source from the content-addressed store, hash-verified

35}
36
37/**
38 * 向上查找 monorepo 根目录(包含 pnpm-workspace.yaml 或根 node_modules)
39 */
40function findMonorepoRoot(startDir) {
41 let dir = startDir;
42 while (dir !== dirname(dir)) {
43 // 检查是否存在 pnpm-workspace.yaml(pnpm monorepo 标志)
44 if (existsSync(join(dir, 'pnpm-workspace.yaml'))) {
45 return dir;
46 }
47 // 检查是否存在 node_modules/.pnpm(pnpm 的依赖目录)
48 if (existsSync(join(dir, 'node_modules', '.pnpm'))) {
49 return dir;
50 }
51 dir = dirname(dir);
52 }
53 return null;
54}
55
56/**
57 * 递归查找匹配的文件
58 */
59function findFiles(dir, pattern, results = [], depth = 0, maxDepth = 10) {
60 if (depth > maxDepth) return results;
61

Callers 1

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected