MCPcopy
hub / github.com/OpenCoworkAI/open-codesign / rm

Function rm

apps/desktop/scripts/after-pack-prune.cjs:38–63  ·  view source on GitHub ↗
(target)

Source from the content-addressed store, hash-verified

36}
37
38function rm(target) {
39 const pending = [target];
40 const directories = [];
41 while (pending.length > 0) {
42 const current = pending.pop();
43 if (!current) continue;
44 let stat;
45 try {
46 stat = fs.lstatSync(current);
47 } catch (err) {
48 if (err?.code === 'ENOENT') continue;
49 throw err;
50 }
51 if (!stat.isDirectory()) {
52 withRmRetry(() => fs.unlinkSync(current));
53 continue;
54 }
55 directories.push(current);
56 for (const entry of fs.readdirSync(current)) {
57 pending.push(path.join(current, entry));
58 }
59 }
60 for (const dir of directories.reverse()) {
61 withRmRetry(() => fs.rmdirSync(dir));
62 }
63}
64
65function existingDirs(paths) {
66 return paths.filter((dir) => fs.existsSync(dir) && fs.statSync(dir).isDirectory());

Callers 15

loader.test.tsFile · 0.85
exportPdfFunction · 0.85
renderSlideScreenshotsFunction · 0.85
renderArtifactBodyHtmlFunction · 0.85
runPreviewFunction · 0.85
verifyWithSystemChromeFunction · 0.85
makeRuntimeVerifierFunction · 0.85

Calls 1

withRmRetryFunction · 0.85

Tested by

no test coverage detected