[英]How do I not print a command in the terminal using node-pty and xterm?
I'm using xterm.js, node-pty, and electron to build a node repl like terminal (similar to repl.it).我正在使用 xterm.js、node-pty 和电子来构建像终端一样的节点 repl(类似于 repl.it)。 I'm using this piece of code to run the file and output it to the terminal:我正在使用这段代码来运行文件并将其输出到终端:
ptyProcess.write("vm.runInNewContext(fs.readFileSync('dir/file.js', 'utf8'))\\r")
But I always get this printed to the terminal:但我总是把它打印到终端:
> vm.runInNewContext(fs.readFileSync('dir/file.js', 'utf8'))
5
>
I know ptyProcess.write()
writes to the terminal, but is there a way to run a command without printing it to the terminal?我知道ptyProcess.write()
写入终端,但是有没有办法运行命令而不将其打印到终端? How can I get the terminal to print something like this:我怎样才能让终端打印这样的东西:
>
5
>
use ptyProcess.on('data', function(data){})
to filter data使用ptyProcess.on('data', function(data){})
过滤数据
xterm.js docs link: onevent-callback xterm.js 文档链接: onevent-callback
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.