Repository navigation
Expand file tree
/
Copy pathcleanup.js
More file actions
46 lines (40 loc) · 1.62 KB
/
Copy pathcleanup.js
File metadata and controls
46 lines (40 loc) · 1.62 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
const path = require("path");
const fs = require("fs");
const os = require("os");
// Clean build directories
console.log("🧹 Cleaning build directories...");
const dirsToClean = ["dist/", "src/dist/", "node_modules/.cache/"];
dirsToClean.forEach((dir) => {
if (fs.existsSync(dir)) {
fs.rmSync(dir, { recursive: true, force: true });
console.log(`✅ Cleaned: ${dir}`);
} else {
console.log(`ℹ️ Directory not found: ${dir}`);
}
});
// Clean development database
console.log("🗄️ Cleaning development database...");
try {
// Electron's appData folder; development builds keep their userData in
// OpenWhispr-development inside it (configureChannelUserDataPath in main.js)
const appDataPath =
process.platform === "darwin"
? path.join(os.homedir(), "Library", "Application Support")
: process.platform === "win32"
? process.env.APPDATA || os.homedir()
: process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config");
const devDbPath = path.join(appDataPath, "OpenWhispr-development", "transcriptions-dev.db");
// The database runs in WAL mode, so its -wal and -shm files go with it
const devDbFiles = [devDbPath, `${devDbPath}-wal`, `${devDbPath}-shm`].filter((file) =>
fs.existsSync(file)
);
if (devDbFiles.length > 0) {
devDbFiles.forEach((file) => fs.unlinkSync(file));
console.log(`✅ Development database cleaned: ${devDbPath}`);
} else {
console.log("ℹ️ No development database found to clean");
}
} catch (error) {
console.error("❌ Error cleaning database files:", error.message);
}
console.log("✨ Cleanup completed successfully!");