MCPcopy Index your code
hub / github.com/code-pushup/cli / materializeTree

Function materializeTree

testing/test-nx-utils/src/lib/utils/tree.ts:6–22  ·  view source on GitHub ↗
(tree: Tree, targetFolder: string)

Source from the content-addressed store, hash-verified

4import { ensureDirectoryExists } from '@code-pushup/test-utils';
5
6export async function materializeTree(tree: Tree, targetFolder: string) {
7 const changes = tree.listChanges();
8 await Promise.all(
9 changes.map(async change => {
10 const filePath = path.join(targetFolder, change.path);
11
12 if (change.type === 'CREATE' || change.type === 'UPDATE') {
13 try {
14 await ensureDirectoryExists(path.dirname(filePath));
15 await writeFile(filePath, change.content?.toString() ?? '');
16 } catch (error) {
17 console.error(`Failed to process file ${filePath}:`, error);
18 }
19 }
20 }),
21 );
22}

Calls 4

ensureDirectoryExistsFunction · 0.90
writeFileFunction · 0.85
toStringMethod · 0.80
errorMethod · 0.80

Tested by 1

addTargetToWorkspaceFunction · 0.72