Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 948
Alex Avatar asked Aug 23 '19 16:08

Alex


1 Answers

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
like image 153
Peter Avatar answered Sep 17 '22 19:09

Peter