简体   繁体   English

VSCode - 任务 2.0.0 版:如何使用“输出”控制台,而不是终端

[英]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.我有一个 0.1.0 版本的任务,我尝试迁移到 2.0.0。

This task simply transpiles Typescript to Javascript using a Gulp script.此任务只是使用 Gulp 脚本将 Typescript 转换为 Javascript。 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!).输出显示在“输出”控制台中,不涉及终端,我希望它保持这种状态(主要是因为臭名昭著的消息“ Terminal will be reused by tasks, press any key to close it. ”在终端中任何命令的结尾!)。

I can't see how to migrate this task to version 2.0.0 so no terminal is involved!我看不到如何将此任务迁移到 2.0.0 版,因此不涉及终端!

Here's the version 0.1.0 :这是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 :这是我目前对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?我怎样才能让它使用输出控制台

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.您需要实现CustomExecution并获取命令的输出。 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');

尝试将"reveal": "always",改为"reveal": "never",

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM