forked from heyito/ito
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean-app-data.js
More file actions
31 lines (27 loc) · 896 Bytes
/
clean-app-data.js
File metadata and controls
31 lines (27 loc) · 896 Bytes
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
#!/usr/bin/env node
const os = require('os')
const fs = require('fs')
const path = require('path')
const platform = os.platform()
const appNames = ['Ito-dev', 'Ito-local', 'Ito-prod', 'Ito']
function getAppDataPath(appName) {
if (platform === 'darwin') {
return path.join(os.homedir(), 'Library', 'Application Support', appName)
} else if (platform === 'win32') {
return path.join(
process.env.APPDATA || path.join(os.homedir(), 'AppData', 'Roaming'),
appName,
)
} else {
return path.join(os.homedir(), '.config', appName.toLowerCase())
}
}
for (const appName of appNames) {
const appDataPath = getAppDataPath(appName)
if (fs.existsSync(appDataPath)) {
fs.rmSync(appDataPath, { recursive: true, force: true })
console.log(`✓ Removed app data from: ${appDataPath}`)
} else {
console.log(`ℹ No app data found at: ${appDataPath}`)
}
}