Skip to content

Commit

Permalink
feat(ui): auto clean projects list
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed May 23, 2018
1 parent 133cdfb commit d2a9d0f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/@vue/cli-ui/src/graphql-api/connectors/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d2a9d0f

Please sign in to comment.