Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. * Open bash terminal and attach it
  2. */
  3. var term = pty.spawn(process.platform === 'win32' ? 'cmd.exe' : 'bash', [], {
  4. name: 'xterm-color',
  5. cols: 80,
  6. rows: 24,
  7. cwd: 'process.env.PWD',
  8. env: process.env
  9. });
  10. term.on('data', function(data) {
  11. try {
  12. ws.send(data);
  13. } catch (ex) {
  14. // The WebSocket is not open, ignore
  15. }
  16. });
  17. ws.on('message', function(msg) {
  18. term.write(msg);
  19. console.log(term);
  20. });
  21.  
  22. ws.on('close', function () {
  23. console.log('close');
  24. process.kill(term.pid);
  25. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement