1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-24 08:12:24 +02:00
joplin/packages/tools/clean.js

37 lines
850 B
JavaScript

const { readdir, stat, rm } = require('fs/promises');
const { resolve } = require('path');
const rootDir = resolve(__dirname, '../..');
const packageDir = `${rootDir}/packages`;
const main = async () => {
const itemNames = await readdir(packageDir);
const toDeletes = [];
for (const itemName of itemNames) {
const fullPath = `${packageDir}/${itemName}`;
const s = await stat(fullPath);
if (!s.isDirectory()) continue;
const nodeModules = `${fullPath}/node_modules`;
toDeletes.push(nodeModules);
}
toDeletes.push(`${rootDir}/node_modules`);
const promises = [];
for (const toDelete of toDeletes) {
console.info(`Delete: ${toDelete}`);
promises.push(rm(toDelete, { force: true, recursive: true }));
}
await Promise.all(promises);
};
main().catch((error) => {
console.error('Fatal error', error);
process.exit(1);
});