Skip to content

Commit 0a5a447

Browse files
authored
Merge pull request #8 from HenryHey/feature/runFromMac
Updated run command so it can launch pico8 from Mac
2 parents 4afedf1 + 3fa51e5 commit 0a5a447

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/extension.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22
import * as vscode from 'vscode';
33
import * as process from 'child_process';
4+
import * as os from 'os';
45
import * as path from 'path';
56

67
export function activate(context: vscode.ExtensionContext) {
@@ -28,8 +29,17 @@ export function activate(context: vscode.ExtensionContext) {
2829
}
2930

3031
document.save().then(s => {
32+
let runCommand = `"${picoPath}" -run "${filename}" ${additionalParams}`;
33+
if (os.type() === "Darwin") {
34+
// Using quotes in runCommand gave error, so we replace
35+
// all the spaces with a slash+space
36+
picoPath = picoPath.split(' ').join('\\ ');
37+
filename = filename.split(' ').join('\\ ');
38+
runCommand = `open ${picoPath} --args -run ${filename} ${additionalParams}`;
39+
}
40+
3141
// Would be good to set the root path to the folder the file is in, but doesn't seem to be a commandline option?
32-
process.exec(`"${picoPath}" -run "${filename}" ${additionalParams}`, (err, stdout, stderr) => {
42+
process.exec(runCommand, (err, stdout, stderr) => {
3343
if (stdout && stdout.length > 0) {
3444
console.log(`pico8 output: ${stdout}`);
3545
}

0 commit comments

Comments
 (0)