Skip to content

Sublime Text 3 Build Systems

Marcin Ignac edited this page Feb 23, 2015 · 3 revisions

Opening and relaunching with PlaskLauncher is tedious so add a Build System.

Now you can select Plask from Tools -> Build System -> Plask and use Cmd+B to open currently edited JS file in Plask.

Run in Plask

Runs currently open .js file in Plask

Plask.sublime-build

{
  "cmd" : ["path/to/Plask.app/Contents/MacOS/Plask", "$file"]
}

Run Plask Project

Searchers current directory for main.js and runs it in Plask. If not found it goes recursively up until root of the file system.

PlaskProject.sublime-build

{
  "cmd" : ["/usr/local/bin/node", "path/to/launchplaskproject.js", "path/to/Plask.app/Contents/MacOS/Plask", "$file"]
}

You will also need to create launchplaskproject.js script somewhere:

var path = require('path');
var fs = require('fs');
var spawn = require('child_process').spawn;

var plaskPath = process.argv[2];
var scriptPath = process.argv[3];
var dir = path.dirname(scriptPath);

var iterationCount = 0;
while(dir != '/' && ++iterationCount < 50) {
  var mainFile = path.join(dir,'/','main.js');
  if (fs.existsSync(mainFile)) {
    console.log(dir);
    var child = spawn(plaskPath,[mainFile], {cwd:dir+'/'});
    child.on('exit', function() {
    })
    child.stdout.on('data', function(data) {
      console.log(data.toString());
    });
    child.stderr.on('data', function(data) {
      console.log(data.toString());
    });
    break;
  }
  else {
    dir = path.resolve(path.join(dir, '/', '..'));
  }
}

if (dir == '/') {
  var mainFile = scriptPath;
  var child = spawn(plaskPath,[mainFile], {cwd:dir+'/'});
    child.on('exit', function() {
  })
  child.stdout.on('data', function(data) {
    console.log(data.toString());
  });
  child.stderr.on('data', function(data) {
    console.log(data.toString());
  });
}
Clone this wiki locally