MCPcopy Create free account
hub / github.com/modelcontextprotocol/mcpb / getAllFiles

Function getAllFiles

src/node/files.ts:79–109  ·  view source on GitHub ↗
(
  dirPath: string,
  baseDir: string = dirPath,
  fileList: Record<string, Uint8Array> = {},
  additionalPatterns: string[] = [],
)

Source from the content-addressed store, hash-verified

77}
78
79export function getAllFiles(
80 dirPath: string,
81 baseDir: string = dirPath,
82 fileList: Record<string, Uint8Array> = {},
83 additionalPatterns: string[] = [],
84): Record<string, Uint8Array> {
85 const files = readdirSync(dirPath);
86
87 const ignoreChecker = buildIgnoreChecker(additionalPatterns);
88
89 for (const file of files) {
90 const filePath = join(dirPath, file);
91 const relativePath = relative(baseDir, filePath);
92
93 if (ignoreChecker.ignores(relativePath)) {
94 continue;
95 }
96
97 const stat = statSync(filePath);
98
99 if (stat.isDirectory()) {
100 getAllFiles(filePath, baseDir, fileList, additionalPatterns);
101 } else {
102 // Use forward slashes in zip file paths
103 const zipPath = relativePath.split(sep).join("/");
104 fileList[zipPath] = readFileSync(filePath);
105 }
106 }
107
108 return fileList;
109}
110
111interface FileWithPermissions {
112 data: Uint8Array;

Callers 1

mcpbignore.test.tsFile · 0.85

Calls 1

buildIgnoreCheckerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…