Skip to content

Commit 16ee949

Browse files
committed
clean script improvements
1 parent 771266d commit 16ee949

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

packages/compass-web/scripts/clean-dts.mjs

100644100755
Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
#!/usr/bin/env node
22

3-
//@ts-check
4-
5-
import fs from 'node:fs';
3+
import fs from 'node:fs/promises';
64
import path from 'node:path';
7-
import process from 'node:process';
85

9-
const distDir = path.join(process.cwd(), 'dist');
10-
const keepFiles = new Set(['compass-web.d.ts', 'compass-web.d.ts.map']);
6+
const distDir = path.join(import.meta.dirname, '..', 'dist');
117

12-
for (const file of fs.readdirSync(distDir)) {
13-
if (
14-
(file.endsWith('.d.ts') || file.endsWith('.d.ts.map')) &&
15-
!keepFiles.has(file)
16-
) {
17-
fs.unlinkSync(path.join(distDir, file));
18-
console.log(`Deleted: ${file}`);
19-
}
20-
}
8+
await Promise.all(
9+
(
10+
await fs.readdir(distDir)
11+
)
12+
.filter((file) => file.endsWith('.d.ts') || file.endsWith('.d.ts.map'))
13+
.filter((file) => file !== 'compass-web.d.ts')
14+
.map((file) => fs.unlink(path.join(distDir, file)))
15+
);

0 commit comments

Comments
 (0)