Skip to content

Commit 5210778

Browse files
committed
more sensible err handling
1 parent d9b891a commit 5210778

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

lib/runtime/environments.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function consumeStatusBar (statusBar) {
3131
const showTile = () => tileDom.style.display = ''
3232
const hideTile = () => tileDom.style.display = 'none'
3333
const updateTile = (proj) => {
34-
if (!proj) return
34+
if (!proj) return hideTile()
3535
projectName = proj.name
3636
dom.innerText = 'Env: ' + projectName
3737
projectPath = proj.path
@@ -55,20 +55,24 @@ export function consumeStatusBar (statusBar) {
5555
}
5656
} else {
5757
client.require('choose environment', () => {
58-
const p = allProjects()
59-
.then(proj => {
60-
return proj.map(proj => {
58+
allProjects()
59+
.then(projs => {
60+
if (!projs) throw '`allProject` handler unsupported'
61+
if (projs.length === 0) throw 'no environment found'
62+
return projs.map(proj => {
6163
proj.primary = proj.name
6264
proj.secondary = proj.path
6365
return proj
6466
})
6567
})
68+
.then(projs => {
69+
show(projs, { active: projectName }).then(proj => {
70+
if (!proj) return
71+
const dir = path.dirname(proj.path)
72+
activateProject(dir)
73+
})
74+
})
6675
.catch(err => console.log(err))
67-
show(p, { active: projectName }).then(proj => {
68-
if (!proj) return
69-
const dir = path.dirname(proj.path)
70-
activateProject(dir)
71-
})
7276
})
7377
}
7478
}

0 commit comments

Comments
 (0)