MCPcopy Create free account
hub / github.com/SoCreate/angular-playground / fromDir

Function fromDir

projects/cli/src/from-dir.ts:14–36  ·  view source on GitHub ↗

* Recursively apply callback to files in a directory (and sub-directories) that match the * provided regular expression

(rootPath: string, startPath: string, filter: RegExp, excludeDirectoryFilter: RegExp | null, callback: Function)

Source from the content-addressed store, hash-verified

12 * provided regular expression
13 */
14function fromDir(rootPath: string, startPath: string, filter: RegExp, excludeDirectoryFilter: RegExp | null, callback: Function) {
15 if (!existsSync(startPath)) {
16 throw new Error(`No Directory Found: ${startPath}`);
17 }
18
19 const files = readdirSync(startPath);
20 for (let i = 0; i < files.length; i++) {
21 const filename = joinPath(startPath, files[i]);
22 const stat = lstatSync(filename);
23
24 if (stat.isDirectory()) {
25 if (excludeDirectoryFilter) {
26 if (!excludeDirectoryFilter.test(filename)) {
27 fromDir(rootPath, filename, filter, excludeDirectoryFilter, callback);
28 }
29 } else {
30 fromDir(rootPath, filename, filter, excludeDirectoryFilter, callback);
31 }
32 } else if (filter.test(filename)) {
33 callback(filename, rootPath);
34 }
35 }
36}

Callers 1

fromDirMultipleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected