1
1
import { ChildProcess , spawn } from 'child_process' ;
2
- import { commands , ExtensionContext , Uri , WebviewView , WebviewViewProvider , WebviewViewResolveContext , window , workspace } from 'vscode' ;
2
+ import { commands , ExtensionContext , Uri , WebviewView , WebviewViewProvider , WebviewViewResolveContext , window , workspace } from 'vscode' ;
3
3
import { state } from './extension' ;
4
4
import { dirname } from 'path' ;
5
5
import * as treeKill from 'tree-kill' ;
@@ -11,7 +11,7 @@ export default function setupConsole(context: ExtensionContext) {
11
11
12
12
const register = window . registerWebviewViewProvider ( 'processingConsoleView' , provider ) ;
13
13
14
- const startSketch = commands . registerCommand ( 'processing.sketch.run' , ( resource : Uri ) => {
14
+ const startSketch = commands . registerCommand ( 'processing.sketch.run' , ( resource : Uri , extraArguments : string [ ] ) => {
15
15
const autosave = workspace
16
16
. getConfiguration ( 'processing' )
17
17
. get < boolean > ( 'autosave' ) ;
@@ -25,22 +25,22 @@ export default function setupConsole(context: ExtensionContext) {
25
25
resource = editor . document . uri ;
26
26
}
27
27
}
28
-
28
+
29
29
if ( ! resource ) {
30
30
return ;
31
31
}
32
32
commands . executeCommand ( 'processingConsoleView.focus' ) ;
33
33
commands . executeCommand ( 'processing.sketch.stop' ) ;
34
-
34
+
35
35
const proc = spawn (
36
36
state . selectedVersion . path ,
37
- [ 'cli' , `--sketch=${ dirname ( resource . fsPath ) } ` , '--run' ] ,
37
+ [ 'cli' , `--sketch=${ dirname ( resource . fsPath ) } ` , ... extraArguments , '--run' ] ,
38
38
{
39
39
shell : false ,
40
40
}
41
41
) ;
42
42
proc . stdout . on ( "data" , ( data ) => {
43
- if ( proc != sketchProcesses [ 0 ] ) {
43
+ if ( proc != sketchProcesses [ 0 ] ) {
44
44
// If this is not the most recent process, ignore its output
45
45
return ;
46
46
}
@@ -60,7 +60,7 @@ export default function setupConsole(context: ExtensionContext) {
60
60
commands . executeCommand ( 'setContext' , 'processing.sketch.running' , sketchProcesses . length > 0 ) ;
61
61
} ) ;
62
62
provider . webview ?. show ?.( true ) ;
63
- provider . webview ?. webview . postMessage ( { type : 'clear' } ) ;
63
+ provider . webview ?. webview . postMessage ( { type : 'clear' } ) ;
64
64
sketchProcesses . unshift ( proc ) ;
65
65
commands . executeCommand ( 'setContext' , 'processing.sketch.running' , true ) ;
66
66
} ) ;
@@ -75,11 +75,17 @@ export default function setupConsole(context: ExtensionContext) {
75
75
}
76
76
} ) ;
77
77
78
+ const buildSketch = commands . registerCommand ( 'processing.sketch.export' , ( ) => {
79
+ commands . executeCommand ( 'processing.sketch.run' , undefined , [ '--export' ] ) ;
80
+ } ) ;
81
+
82
+
78
83
context . subscriptions . push (
79
84
register ,
80
85
startSketch ,
81
86
restartSketch ,
82
- stopSketch
87
+ stopSketch ,
88
+ buildSketch
83
89
) ;
84
90
}
85
91
0 commit comments