MCPcopy Create free account
hub / github.com/MirrowApp/mirrow / processDirectory

Function processDirectory

packages/cli/src/runner.ts:97–129  ·  view source on GitHub ↗
(
  inputDir: string,
  outputDir: string,
  depth: number | typeof Infinity
)

Source from the content-addressed store, hash-verified

95}
96
97async function processDirectory(
98 inputDir: string,
99 outputDir: string,
100 depth: number | typeof Infinity
101): Promise<void> {
102 await fs.mkdir(outputDir, { recursive: true });
103 const entries = await fs.readdir(inputDir, { withFileTypes: true });
104
105 for (const entry of entries) {
106 const inputPath = path.join(inputDir, entry.name);
107 const outputPath = path.join(outputDir, entry.name);
108
109 if (entry.isDirectory()) {
110 if (depth === 0) {
111 continue;
112 }
113 const nextDepth = depth === Infinity ? Infinity : depth - 1;
114 await processDirectory(inputPath, outputPath, nextDepth);
115 continue;
116 }
117
118 if (!entry.isFile()) {
119 continue;
120 }
121
122 const ext = path.extname(entry.name);
123 if (ext === MIRROW_EXTENSION) {
124 await compileMirrowFile(inputPath, toSvgPath(outputDir, entry.name));
125 } else {
126 await copyAsset(inputPath, outputPath);
127 }
128 }
129}
130
131function resolveOutputFilePath(output: string): string {
132 return path.extname(output) ? output : `${output}.svg`;

Callers 1

runMirrowFunction · 0.85

Calls 3

compileMirrowFileFunction · 0.85
toSvgPathFunction · 0.85
copyAssetFunction · 0.85

Tested by

no test coverage detected