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

9

我有一个版本为0.1.0的任务,想要将其迁移到2.0.0版本。

这个任务仅是使用Gulp脚本将Typescript转译成Javascript。输出结果会显示在“output”控制台中,没有终端参与,我希望保持这种方式(主要是因为终端中的臭名昭著的消息 “Terminal will be reused by tasks, press any key to close it.” 会在终端中的任何命令结束时出现!)

我不知道如何将此任务迁移到2.0.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"
        }
    ]
}

这是我目前版本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
            }
        }
    ]
}

这将在集成终端中显示输出。

我该如何让它使用输出控制台呢?

2个回答

1
使用任务面板是推荐的方法,但如果您确实需要使用输出面板,则需要实现CustomExecution并获取您的命令的输出。然后要写入输出面板,首先需要创建一个专用的输出通道并向其写入内容:
let outputChannel = vscode.window.createOutputChannel('channelName');
outputChannel.appendLine('message');

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

我有同样的问题。有解决这个问题的有效方法吗? - Martin Schagerl

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接