Skip to content

Instantly share code, notes, and snippets.

@beastaugh
Created May 17, 2010 00:54
Show Gist options
  • Save beastaugh/403284 to your computer and use it in GitHub Desktop.
Save beastaugh/403284 to your computer and use it in GitHub Desktop.
Run JavaScript from TextMate
var sys = require("sys"),
fs = require("fs"),
sc = process.binding('evals').Script;
this.run = function(path) {
var contents = fs.readFileSync(path.toString()),
context = {print: function(v) {sys.puts(v + "<br>")}},
evaled = sc.runInNewContext(contents, context);
};
#!/usr/bin/env node
var nodeTM = require('/path/to/node_tm');
nodeTM.run([process.ENV.TM_FILEPATH]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment