MCPcopy
hub / github.com/neomjs/neo / scan

Function scan

ai/scripts/maintenance/purgeTestCollections.mjs:166–177  ·  view source on GitHub ↗
(dir, predicate)

Source from the content-addressed store, hash-verified

164 const removed = [];
165
166 const scan = async (dir, predicate) => {
167 if (!await fsModule.pathExists(dir)) return;
168
169 for (const name of await fsModule.readdir(dir)) {
170 if (predicate(name)) {
171 const target = path.join(dir, name);
172 removed.push(target);
173 log(` 🗑️ ${apply ? 'Removing' : '[dry-run] would remove'} ${target}`);
174 if (apply) await fsModule.remove(target);
175 }
176 }
177 };
178
179 await scan(path.join(dataDir, 'sqlite'), name => name.startsWith('test-daemon-'));
180 await scan(dataDir, name => name.startsWith('wake-daemon-test-'));

Callers 1

cleanDaemonSqliteResidueFunction · 0.85

Calls 4

readdirMethod · 0.80
logFunction · 0.50
pushMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected