index.js 578 B

123456789101112131415161718192021222324
  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.events
  7. .channel('core-shell')
  8. .after('cmd',(req,res,e) => {
  9. if(e.count != 0) return;
  10. e.wait();
  11. var shcmd = req.cmd + " " + req.args.join(" ");
  12. var proc = child.exec(shcmd);
  13. proc.stdout.pipe(res);
  14. proc.stderr.pipe(process.stderr);
  15. proc.on('close',function() {
  16. e.done();
  17. });
  18. });
  19. }
  20. module.exports.bundleStart = bundleStart;