27 lines
671 B
JavaScript
27 lines
671 B
JavaScript
|
|
/**
|
|||
|
|
* 精简版清理:.turbo、根 node_modules/.cache;可选 --del-lock 删除 pnpm-lock.yaml
|
|||
|
|
*/
|
|||
|
|
import { existsSync, rmSync } from 'node:fs';
|
|||
|
|
import path from 'node:path';
|
|||
|
|
import process from 'node:process';
|
|||
|
|
|
|||
|
|
const root = process.cwd();
|
|||
|
|
const delLock = process.argv.includes('--del-lock');
|
|||
|
|
|
|||
|
|
const paths = ['.turbo', path.join(root, 'node_modules/.cache')];
|
|||
|
|
|
|||
|
|
for (const p of paths) {
|
|||
|
|
if (existsSync(p)) {
|
|||
|
|
rmSync(p, { recursive: true, force: true });
|
|||
|
|
console.log('removed', p);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (delLock) {
|
|||
|
|
const lockfile = path.join(root, 'pnpm-lock.yaml');
|
|||
|
|
if (existsSync(lockfile)) {
|
|||
|
|
rmSync(lockfile);
|
|||
|
|
console.log('removed pnpm-lock.yaml');
|
|||
|
|
}
|
|||
|
|
}
|