Skip to content

Instantly share code, notes, and snippets.

@JustinBeckwith
Created January 5, 2016 17:04
Show Gist options
  • Save JustinBeckwith/928af8de7cac7538e7c5 to your computer and use it in GitHub Desktop.
Save JustinBeckwith/928af8de7cac7538e7c5 to your computer and use it in GitHub Desktop.
deasync sample
{
"name": "inittest",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"deasync": "^0.1.4"
}
}
var http = require('http');
var deasync = require('deasync');
var cp = require('child_process');
var exec = deasync(cp.exec);
console.log('done');
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
try{
response.write(exec('ls -la'));
}
catch(err){
console.log(err);
}
response.end("Hello World\n");
});
server.listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment