forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnuke.mjs
More file actions
executable file
·35 lines (27 loc) · 1.02 KB
/
Copy pathnuke.mjs
File metadata and controls
executable file
·35 lines (27 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env node
import { access, constants, readdir } from 'node:fs/promises';
import { join, resolve } from 'node:path';
import { $ } from 'zx';
const $$ = $({
env: { NODE_ENV: 'production' },
verbose: !!process.env.VERBOSE,
});
const DIRECTORIES_TO_CLEAN = ['.coverage', '.turbo', 'coverage', 'dist', 'node_modules'];
// Iterate over `packages/*`
try {
const packagesDir = resolve('packages');
await access(packagesDir, constants.R_OK);
try {
const packages = await readdir(packagesDir);
const promises = packages.map(
dir => $$`rm -rf ${DIRECTORIES_TO_CLEAN.map(directory => join(join(packagesDir, dir), directory))}`,
);
await Promise.all(promises).then(() => void console.log(`Cleaned ${promises.length} packages`));
} catch (error) {
console.error(error);
}
} catch {
console.log('Cannot access packages directory');
}
await $$`rm -rf .turbo`.then(() => console.log('Removed root .turbo directory'));
await $$`rm -rf node_modules`.then(() => console.log('Removed root node_modules'));