playwright/utils/build/clean.js
Max Schmitt 5f366088be
chore: get rid of rimraf package (#27790)
This seems more reliable nowadays as rimraf.

https://github.com/microsoft/playwright/issues/27712

---------

Signed-off-by: Max Schmitt <max@schmitt.mx>
2023-10-26 19:41:00 +02:00

18 lines
620 B
JavaScript

// @ts-check
const { workspace } = require('../workspace');
const fs = require('fs');
const path = require('path');
const rmSync = (dir) => fs.rmSync(dir, { recursive: true, force: true, maxRetries: 10 });
for (const pkg of workspace.packages()) {
rmSync(path.join(pkg.path, 'node_modules'));
rmSync(path.join(pkg.path, 'lib'));
rmSync(path.join(pkg.path, 'src', 'generated'));
const bundles = path.join(pkg.path, 'bundles');
if (fs.existsSync(bundles) && fs.statSync(bundles).isDirectory()) {
for (const bundle of fs.readdirSync(bundles))
rmSync(path.join(bundles, bundle, 'node_modules'));
}
}