Skip to content

Commit d2a9d0f

Browse files
author
Guillaume Chau
committedMay 23, 2018
feat(ui): auto clean projects list
1 parent 133cdfb commit d2a9d0f

File tree

1 file changed

+17
-1
lines changed
  • packages/@vue/cli-ui/src/graphql-api/connectors

1 file changed

+17
-1
lines changed
 

‎packages/@vue/cli-ui/src/graphql-api/connectors/projects.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,23 @@ let onInstallProgress = null
3232
let onInstallLog = null
3333

3434
function list (context) {
35-
return context.db.get('projects').value()
35+
let projects = context.db.get('projects').value()
36+
projects = autoClean(projects, context)
37+
return projects
38+
}
39+
40+
function autoClean (projects, context) {
41+
let result = []
42+
for (const project of projects) {
43+
if (fs.existsSync(project.path)) {
44+
result.push(project)
45+
}
46+
}
47+
if (result.length !== projects.length) {
48+
console.log(`Auto cleaned ${projects.length - result.length} projects (folder not found).`)
49+
context.db.set('projects', result).write()
50+
}
51+
return result
3652
}
3753

3854
function getCurrent (context) {

0 commit comments

Comments
 (0)
Please sign in to comment.