-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathextension.ts
29 lines (21 loc) · 847 Bytes
/
extension.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
import * as vscode from 'vscode';
import cp = require('child_process');
import path = require('path');
export function activate(context: vscode.ExtensionContext) {
let p8Config = vscode.workspace.getConfiguration('pico8');
let disposable = vscode.commands.registerTextEditorCommand('pico8.run', (textEditor: vscode.TextEditor) => {
let fileName = textEditor.document.fileName;
let args = ["-windowed", "1", "-run", fileName];
let workspace = vscode.workspace;
if (workspace) {
args.push("-home", workspace.rootPath);
}
cp.execFile(p8Config['executablePath'], args, { env: process.env }, (err, stdout, stderr) => {
if (err) {
console.log(err);
}
})
});
context.subscriptions.push(disposable);
}