-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcleanup.js
More file actions
64 lines (57 loc) · 1.64 KB
/
cleanup.js
File metadata and controls
64 lines (57 loc) · 1.64 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env node
/**
* Cleanup script to remove old directories after restructuring
*/
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
// Directories to be removed
const oldDirectories = [
'discord_bot',
'telegram_bot',
'whatsapp_bot',
'frontend'
];
// Files to be removed
const oldFiles = [
'server.js'
];
console.log('Starting cleanup process...');
// Remove old directories
oldDirectories.forEach(dir => {
const dirPath = path.join(__dirname, dir);
if (fs.existsSync(dirPath)) {
try {
console.log(`Removing directory: ${dir}`);
if (process.platform === 'win32') {
// Windows requires a different command for removing directories with content
execSync(`rmdir /s /q "${dirPath}"`);
} else {
execSync(`rm -rf "${dirPath}"`);
}
console.log(`Successfully removed: ${dir}`);
} catch (error) {
console.error(`Error removing directory ${dir}:`, error.message);
}
} else {
console.log(`Directory already removed: ${dir}`);
}
});
// Remove old files
oldFiles.forEach(file => {
const filePath = path.join(__dirname, file);
if (fs.existsSync(filePath)) {
try {
console.log(`Removing file: ${file}`);
fs.unlinkSync(filePath);
console.log(`Successfully removed: ${file}`);
} catch (error) {
console.error(`Error removing file ${file}:`, error.message);
}
} else {
console.log(`File already removed: ${file}`);
}
});
console.log('Cleanup completed!');
console.log('The project has been successfully restructured.');
console.log('You can now run the application with: npm start');