index.js 573 B

1234567891011121314151617181920212223242526
  1. var log = require('hlogger').createLogger('shell-test');
  2. var child = require('child_process');
  3. function bundleStart(context) {
  4. log.info("Command provider installed");
  5. // Create a bash and transport commands
  6. context.after('.*:cmd:.*',(req,res,e) => {
  7. if(e.count >0) return;
  8. e.wait();
  9. var shcmd = req.cmd + " " + req.args.join(" ");
  10. var proc = child.exec(shcmd);
  11. res.write("\n");
  12. proc.stdout.pipe(res);
  13. proc.stderr.pipe(process.stderr);
  14. proc.on('close',function() {
  15. e.done();
  16. });
  17. e.done();
  18. });
  19. }
  20. module.exports.bundleStart = bundleStart;