Skip to content

Commit a218317

Browse files
committed
export julia-client:set-working-environment command
1 parent 5210778 commit a218317

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

lib/package/commands.coffee

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ module.exports =
194194
'julia-client:activate-default-environment': (ev) ->
195195
requireClient 'activate an environment', ->
196196
juno.runtime.evaluation.activateDefaultProject()
197+
'julia-client:set-working-environment': (ev) ->
198+
juno.runtime.environments.chooseEnvironment()
197199

198200
deactivate: ->
199201
@subs.dispose()

lib/package/menu.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ module.exports =
4747
{label: 'Environment in Current File\'s Folder', command: 'julia-client:activate-environment-in-current-folder'}
4848
{label: 'Environment in Parent Folder', command: 'julia-client:activate-environment-in-parent-folder'}
4949
{label: 'Default Environment', command: 'julia-client:activate-default-environment'}
50+
{label: 'Set Working Environment', command: 'julia-client:set-working-environment'}
5051
]
5152
}
5253
{label: 'Set Working Module', command: 'julia-client:set-working-module'}

lib/runtime/environments.js

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,7 @@ export function consumeStatusBar (statusBar) {
5454
})
5555
}
5656
} else {
57-
client.require('choose environment', () => {
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 => {
63-
proj.primary = proj.name
64-
proj.secondary = proj.path
65-
return proj
66-
})
67-
})
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-
})
75-
.catch(err => console.log(err))
76-
})
57+
chooseEnvironment()
7758
}
7859
}
7960

@@ -97,3 +78,27 @@ export function consumeStatusBar (statusBar) {
9778
hideTile()
9879
return subs
9980
}
81+
82+
export function chooseEnvironment () {
83+
client.require('choose environment', () => {
84+
allProjects()
85+
.then(({ projects, active }) => {
86+
if (!projects) throw '`allProject` handler unsupported'
87+
if (projects.length === 0) throw 'no environment found'
88+
projects = projects.map(proj => {
89+
proj.primary = proj.name
90+
proj.secondary = proj.path
91+
return proj
92+
})
93+
return { projects, active }
94+
})
95+
.then(({ projects, active }) => {
96+
show(projects, { active }).then(proj => {
97+
if (!proj) return
98+
const dir = path.dirname(proj.path)
99+
activateProject(dir)
100+
})
101+
})
102+
.catch(err => console.log(err))
103+
})
104+
}

menus/julia-client.cson

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
{label: 'Work in Current Folder', command: 'julia-client:work-in-current-folder'}
2020
{label: 'Activate Environment in Current Folder', command: 'julia-client:activate-environment-in-current-folder'}
2121
{label: 'Activate Environment in Parent Folder', command: 'julia-client:activate-environment-in-parent-folder'}
22+
{label: 'Set Working Environment', command: 'julia-client:set-working-environment'}
2223
{label: 'Set Working Module', command: 'julia-client:set-working-module'}
2324
]
2425
}

0 commit comments

Comments
 (0)