MCPcopy Create free account
hub / github.com/awslabs/llrt / readFilesRecursive

Function readFilesRecursive

build.mjs:18–32  ·  view source on GitHub ↗
(dir, filePredicate)

Source from the content-addressed store, hash-verified

16const SHIMS = new Map();
17const SDK_BUNDLE_MODE = process.env.SDK_BUNDLE_MODE || "NONE"; // "FULL" or "STD" or "NONE"
18
19async function readFilesRecursive(dir, filePredicate) {
20 const dirents = await fs.readdir(dir, { withFileTypes: true });
21 const files = await Promise.all(
22 dirents.map((dirent) => {
23 const filePath = path.join(dir, dirent.name);
24
25 if (dirent.isDirectory()) {
26 return readFilesRecursive(filePath, filePredicate);
27 } else {
28 return filePredicate(filePath) ? filePath : [];
29 }
30 })
31 );
32 return Array.prototype.concat(...files);
33}
34
35const TEST_FILES = await readFilesRecursive(

Callers 1

build.mjsFile · 0.85

Calls 3

joinMethod · 0.80
isDirectoryMethod · 0.80
concatMethod · 0.80

Tested by

no test coverage detected