Skip to content

Commit fcc8f3b

Browse files
authored
Merge pull request #33 from processing/export-sketches
Add export command for Processing sketches
2 parents c59452f + eaf3b65 commit fcc8f3b

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

client/src/setupConsole.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
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';
33
import { state } from './extension';
44
import { dirname } from 'path';
55
import * as treeKill from 'tree-kill';
@@ -11,7 +11,7 @@ export default function setupConsole(context: ExtensionContext) {
1111

1212
const register = window.registerWebviewViewProvider('processingConsoleView', provider);
1313

14-
const startSketch = commands.registerCommand('processing.sketch.run', (resource: Uri) => {
14+
const startSketch = commands.registerCommand('processing.sketch.run', (resource: Uri, extraArguments: string[]) => {
1515
const autosave = workspace
1616
.getConfiguration('processing')
1717
.get<boolean>('autosave');
@@ -25,22 +25,22 @@ export default function setupConsole(context: ExtensionContext) {
2525
resource = editor.document.uri;
2626
}
2727
}
28-
28+
2929
if (!resource) {
3030
return;
3131
}
3232
commands.executeCommand('processingConsoleView.focus');
3333
commands.executeCommand('processing.sketch.stop');
34-
34+
3535
const proc = spawn(
3636
state.selectedVersion.path,
37-
['cli', `--sketch=${dirname(resource.fsPath)}`, '--run'],
37+
['cli', `--sketch=${dirname(resource.fsPath)}`, ...extraArguments, '--run'],
3838
{
3939
shell: false,
4040
}
4141
);
4242
proc.stdout.on("data", (data) => {
43-
if(proc != sketchProcesses[0]) {
43+
if (proc != sketchProcesses[0]) {
4444
// If this is not the most recent process, ignore its output
4545
return;
4646
}
@@ -60,7 +60,7 @@ export default function setupConsole(context: ExtensionContext) {
6060
commands.executeCommand('setContext', 'processing.sketch.running', sketchProcesses.length > 0);
6161
});
6262
provider.webview?.show?.(true);
63-
provider.webview?.webview.postMessage({ type: 'clear'});
63+
provider.webview?.webview.postMessage({ type: 'clear' });
6464
sketchProcesses.unshift(proc);
6565
commands.executeCommand('setContext', 'processing.sketch.running', true);
6666
});
@@ -75,11 +75,17 @@ export default function setupConsole(context: ExtensionContext) {
7575
}
7676
});
7777

78+
const buildSketch = commands.registerCommand('processing.sketch.export', () => {
79+
commands.executeCommand('processing.sketch.run', undefined, ['--export']);
80+
});
81+
82+
7883
context.subscriptions.push(
7984
register,
8085
startSketch,
8186
restartSketch,
82-
stopSketch
87+
stopSketch,
88+
buildSketch
8389
);
8490
}
8591

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@
6767
"command": "processing.sketch.new",
6868
"title": "Create a new Processing Sketch",
6969
"icon": "$(new-file)"
70+
},
71+
{
72+
"command": "processing.sketch.export",
73+
"title": "Export the Processing Sketch"
7074
}
7175
],
7276
"keybindings": [
@@ -225,4 +229,4 @@
225229
"dependencies": {
226230
"tree-kill": "^1.2.2"
227231
}
228-
}
232+
}

0 commit comments

Comments
 (0)