Skip to content

Instantly share code, notes, and snippets.

@yitsushi
Created June 30, 2015 20:38
Show Gist options
  • Save yitsushi/adf0833b1f6b5e62225a to your computer and use it in GitHub Desktop.
Save yitsushi/adf0833b1f6b5e62225a to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
var sys = require("sys"),
spawn = require('child_process').spawn;
/*
* htmlEntities function is from Chris Coyier
* URL: http://css-tricks.com/snippets/javascript/htmlentities-for-javascript/
*/
function htmlEntities(str) {
return String(str).replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
}
(function(path, file) {
console.log("<div style='color: green'>Run "
+ path + "/" + file
+ "</div>");
var app = spawn("node", [path + "/" + file], { cwd: path });
app.stdout.on('data', function(data) {
console.log("<div>"
+ htmlEntities(data)
+ "</div>");
});
app.stderr.on('data', function(data) {
console.log("<div style='color: red'>"
+ htmlEntities(data)
+ "</div>");
});
app.on('exit', function(code) {
console.log('App exited with code ' + code);
});
})(process.env.TM_DIRECTORY, 'app.js');
// by Balazs Nadasdi
// if you find a bug then please send me to [email protected]
// or find me on Google+
#!/usr/bin/env node
var sys = require("sys"),
spawn = require('child_process').spawn;
/*
* htmlEntities function is from Chris Coyier
* URL: http://css-tricks.com/snippets/javascript/htmlentities-for-javascript/
*/
function htmlEntities(str) {
return String(str).replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
}
(function(path, file) {
console.log("<div style='color: green'>Run "
+ file
+ "</div>");
var app = spawn("node", [file], { cwd: path });
app.stdout.on('data', function(data) {
console.log("<div>"
+ htmlEntities(data)
+ "</div>");
});
app.stderr.on('data', function(data) {
console.log("<div style='color: red'>"
+ htmlEntities(data)
+ "</div>");
});
app.on('exit', function(code) {
console.log('App exited with code ' + code);
});
})(process.env.TM_DIRECTORY, process.env.TM_FILEPATH);
// by Balazs Nadasdi
// if you find a bug then please send me to [email protected]
// or find me on Google+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment