-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get input data on output listener method #184
Comments
I'm looking for this same solution. Currently, the only thing I could think to do is to capture the input manually in a variable and compare the output with the last known input on each let lastInput = '';
term.on('data', (data) => {
if(lastInput !== data) {
process.stdout.write(data); // instead of console.log to avoid extra newline characters
}
}
process.stdin.on('readable', () => {
const chunk = process.stdin.read();
if (chunk !== null) {
lastInput = chunk;
term.write(chunk);
}
} The problem with this is that while it seems straight forward, Finally, on top of all of that, stdout doesn't guarantee that the entire string is handed to you on the
My next step is to possibly wait for a newline character before parsing |
SolutionFound this explanation in the process.stdin.setRawMode(true) I would expect it to work with On that note, this repo hasn't had a commit in a year, so I would consider switching to One might be the continuation of the other. I don't know. |
@euroclydon37 node-pty was forked from pty.js about a year ago, here are the main changes:
Checkout the releases for more specifics, 0.4.1 was the first release after forking, 0.6.0 removed pty.js' modification to winpty and updated it to latest. |
Loving it so far. |
I am using
pty.js
in a nodejs application to emulate a interactive terminal. But the I got the input data in the output listener method. Is there a way to get the output data only?Below is my source code:
when running above code, I can see the output:
from the above output you can observe that the input command
echo hello
got printed twice interm.on('data' ...)
function. Is there a way to get ride of the input data from the output listener method?The text was updated successfully, but these errors were encountered: