Comments (4)
@euroclydon37 node-pty was forked from pty.js about a year ago, here are the main changes:
- Better Windows support
- Better support for recent Node versions
- Converted to TS, added some tests
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.
from pty.js.
Loving it so far.
from pty.js.
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 data
event, choosing to ignore the said output if they are equal.
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, data
and chunk
are of different types. Then once you get past that with everything converted to what it needs to be for comparison, you end up with them having different newline characters. My attempt had lastInput
possessing a trailing \n
and data
possessing \r\n
.
Finally, on top of all of that, stdout doesn't guarantee that the entire string is handed to you on the data
event. I would often get something like this.
t
est
bash-3.2$
My next step is to possibly wait for a newline character before parsing data
. I'm just afraid that there will be scenarios where all of this will cause unintended behavior. It would be much better if the echo could be disabled with a configuration option or something.
from pty.js.
Solution
Found this explanation in the node-pty
repo.
process.stdin.setRawMode(true)
I would expect it to work with pty.js
as well.
On that note, this repo hasn't had a commit in a year, so I would consider switching to node-pty
if you're doing anything crucial. I've only recently discovered them, and don't know much about them, but it seems like the community has switched boats.
One might be the continuation of the other. I don't know.
from pty.js.
Related Issues (20)
- In the demo app how would you detect a CTRL + D or the death of the process?
- BUGs on ubuntu16.10 when I install package in atom HOT 2
- Microsoft seems to have work on pty.js HOT 1
- How to enable ipc communication : enable process.send() & child.on('message') ?
- gyp: deps\winpty\winpty.gyp not found (cwd: C:\Program Files\nodejs\node_modules\pty.js) HOT 4
- why is stderr undefined?
- pty.resize - ioctl failed. HOT 1
- Terminal.end does not kill the process
- replace node-waf bindings to node-gyp HOT 3
- bug HOT 6
- apm bug HOT 1
- in Sqlplus, backspace and delete keys are not working while SSH
- Doesnt work on 10.0.0 HOT 4
- Unable to build: ‘class v8::Object’ has no member named ‘ForceSet’ HOT 13
- What are the possible values for the `name` option ?
- node-gyp rebuild error.os:ubuntu16.04
- Cannot create new project and i cannot my npm.version node 12,npm 3.
- .
- active forks
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pty.js.