How to use Terminal API to listen to all terminal output in vscode?

只谈情不闲聊 提交于 2020-01-24 09:37:06

问题


I want to listen to terminal output from extension, such as tsc -w and catch the moment if the output contains similar text:

Found 1 error. Watching for file changes.

Or the error exit code or something like that. Is it possible to do with old API or Proposed API?

Tried:

terminal.onDidWriteData(data => {
    console.log('onDidWriteData: ', data.trim());
});

It just outputs autogenerated rubbish like:

Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved.


回答1:


Looks like it is deprecated in insiders edition. Try using window.onDidWriteTerminalData:

window.onDidWriteTerminalData(event => console.log(event.data.trim()))

Reference

  • https://github.com/microsoft/vscode/issues/78574


来源:https://stackoverflow.com/questions/57630371/how-to-use-terminal-api-to-listen-to-all-terminal-output-in-vscode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!