MCPcopy
hub / github.com/FoalTS/foal / rmDirAndFilesIfExist

Function rmDirAndFilesIfExist

packages/storage/src/local-disk.service.spec.ts:14–31  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

12import { LocalDisk } from './local-disk.service';
13
14function rmDirAndFilesIfExist(path: string) {
15 if (!existsSync(path)) {
16 return;
17 }
18
19 const files = readdirSync(path);
20 for (const file of files) {
21 const stats = statSync(join(path, file));
22
23 if (stats.isDirectory()) {
24 rmDirAndFilesIfExist(join(path, file));
25 } else {
26 unlinkSync(join(path, file));
27 }
28 }
29
30 rmdirSync(path);
31}
32
33describe('LocalDisk', () => {
34

Callers 1

Calls 1

joinFunction · 0.85

Tested by

no test coverage detected