Created
August 28, 2018 00:00
-
-
Save jerch/a592dff6a57770fd59044400d83c5f12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var os = require('os'); | |
var pty = require('./lib/index'); | |
var shell = os.platform() === 'win32' | |
? 'powershell.exe' | |
: 'bash'; | |
process.on('exit', function(c) { | |
console.log('exit ' + c) | |
}); | |
process.on('SIGINT', function(c) { | |
console.log('sigint ' + c); | |
process.exit(); | |
}); | |
var ptyProcess = pty.spawn(shell, [], { | |
name: 'xterm-color', | |
cols: 80, | |
rows: 30, | |
cwd: process.env.HOME, | |
env: process.env | |
}); | |
ptyProcess.on('data', function (data) { | |
console.log(data); | |
}); | |
ptyProcess.write('ls\r'); | |
setTimeout(function() { | |
ptyProcess.kill(); | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment