feat(ui): auto clean projects list

This commit is contained in:
Guillaume Chau
2018-05-23 15:12:20 +02:00
parent 133cdfbf76
commit d2a9d0fc0b

View File

@@ -32,7 +32,23 @@ let onInstallProgress = null
let onInstallLog = null
function list (context) {
return context.db.get('projects').value()
let projects = context.db.get('projects').value()
projects = autoClean(projects, context)
return projects
}
function autoClean (projects, context) {
let result = []
for (const project of projects) {
if (fs.existsSync(project.path)) {
result.push(project)
}
}
if (result.length !== projects.length) {
console.log(`Auto cleaned ${projects.length - result.length} projects (folder not found).`)
context.db.set('projects', result).write()
}
return result
}
function getCurrent (context) {