问题
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