-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathreset-setup.js
More file actions
45 lines (36 loc) · 1.31 KB
/
reset-setup.js
File metadata and controls
45 lines (36 loc) · 1.31 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
36
37
38
39
40
41
42
43
44
45
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
function removeDirectory(dirPath) {
if (fs.existsSync(dirPath)) {
fs.rmSync(dirPath, { recursive: true, force: true });
console.log(`Removed: ${dirPath}`);
}
}
function resetProject() {
const rootDir = __dirname;
const packagesDir = path.join(rootDir, 'packages');
// Clean up packages
if (fs.existsSync(packagesDir)) {
const packages = fs.readdirSync(packagesDir);
packages.forEach(pkg => {
const pkgPath = path.join(packagesDir, pkg);
if (fs.statSync(pkgPath).isDirectory()) {
// Remove node_modules in package
removeDirectory(path.join(pkgPath, 'node_modules'));
// Remove dist in package
removeDirectory(path.join(pkgPath, 'dist'));
}
});
}
// Remove root node_modules
removeDirectory(path.join(rootDir, 'node_modules'));
// Install dependencies
console.log('\nInstalling dependencies...');
execSync('npm install', { stdio: 'inherit' });
// Build project
console.log('\nBuilding project...');
execSync('npm run build', { stdio: 'inherit' });
console.log('\nProject reset completed successfully!');
}
resetProject();