Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode - Tasks version 2.0.0 : how to use the "output" console, not the terminal

I have a task at version 0.1.0 that I try to migrate to 2.0.0.

This task simply transpiles Typescript to Javascript using a Gulp script. The output is shown in the "output" console, there is no terminal involved and I want it to keep it that way (mostly because of the infamous message "Terminal will be reused by tasks, press any key to close it." at the end of any command in the terminal!).

I can't see how to migrate this task to version 2.0.0 so no terminal is involved!

Here's the version 0.1.0 :

{
    "version": "0.1.0",
    "command": "${workspaceRoot}/node_modules/.bin/gulp",
    "isShellCommand": true,
    "showOutput": "always",
    "suppressTaskName": true,
    "tasks": [
        {
            "taskName": "compile",
            "args": [
                "compile",
                "exit"
            ],
            "isBuildCommand": true,
            "problemMatcher": "$tsc"
        }
    ]
}

Here's my current try for version 2.0.0 :

{
    "version": "2.0.0",
    "tasks": [
        {
            "identifier": "compile",
            "type": "shell",
            "taskName": "compile",
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": true,
                "panel": "new"
            },
            "command": "${workspaceRoot}/node_modules/.bin/gulp compile exit",
            "problemMatcher": [
                "$tsc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

This does show the output in the integrated terminal.

How can I make it use the output console instead?

like image 718
electrotype Avatar asked Oct 26 '17 19:10

electrotype


People also ask

How do I run code in output instead of terminal?

Open your C code file in Text Editor, then use shortcut Ctrl+Alt+N , or press F1 and then select/type Run Code , or right click the Text Editor and then click Run Code in context menu, the code will be compiled and run, and the output will be shown in the Output Window.

How do you run code in terminal and not in output in VS Code?

If you don't want it to run in the terminal, then in the Code Runner settings uncheck the “Run in Terminal” option. When you run your code, make sure that you have selected “Code” from the OUTPUT dropdown.


2 Answers

Using the tasks panel is the recommended way to go, but if you really need to use the output panel. You'd need to implement a CustomExecution and get the output of your command. Then to write to the output panel, first you would need to create a dedicated output channel and write to it:

let outputChannel = vscode.window.createOutputChannel('channelName');
outputChannel.appendLine('message');
like image 185
Ivo Reyes Avatar answered Oct 31 '22 02:10

Ivo Reyes


Try change "reveal": "always", to "reveal": "never",

like image 40
Doctor Coder Avatar answered Oct 31 '22 00:10

Doctor Coder