MCPcopy Create free account
hub / github.com/code-pushup/cli / rollback

Function rollback

packages/utils/src/lib/wizard/virtual-fs.ts:95–115  ·  view source on GitHub ↗
(
  written: string[],
  pending: Map<string, PendingEntry>,
  fs: FileSystemAdapter,
  resolve: (filePath: string) => string,
)

Source from the content-addressed store, hash-verified

93}
94
95async function rollback(
96 written: string[],
97 pending: Map<string, PendingEntry>,
98 fs: FileSystemAdapter,
99 resolve: (filePath: string) => string,
100): Promise<void> {
101 await Promise.allSettled(
102 written.map(async filePath => {
103 const entry = pending.get(filePath);
104 if (!entry) {
105 return;
106 }
107 const absolutePath = resolve(filePath);
108 if (entry.original == null) {
109 await fs.unlink(absolutePath);
110 return;
111 }
112 await fs.writeFile(absolutePath, entry.original);
113 }),
114 );
115}

Callers 1

flushFunction · 0.85

Calls 1

resolveFunction · 0.85

Tested by

no test coverage detected