javascript - Visual Studio 代码清理任务

标签 javascript linux typescript visual-studio-code

我正在 Ubuntu 中使用 Visual Studio Code 处理我的 Typescript 项目。我想知道是否有可能执行某种“clean”任务。 这是我的 tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "tasks": [
        {
            "taskName": "tsc",
            "command": "tsc",
            "isShellCommand": true,
            "isBackground": true,
            "problemMatcher": "$tsc"
        },
        {
            "taskName": "clean",
            "linux": {
                "command": "rm",
                "args": [
                    "./src/*.js"
                ],
                "isShellCommand": true
            },
            "isShellCommand": true,
            "isBackground": true
        }
    ]
}

这是我的项目结构。

And here's my project structure.

执行task clean表示没有这样的文件或目录,而执行'pwd'而不是rm表示我处于我的项目的根。 有什么建议吗?这个构建系统如何工作?也许 VS Code 中的环境变量有一些特殊的语法?

最佳答案

在 VSCode 1.14 之后,我们在 VSCode 中有一个新的任务管理器。我在 ubuntu 上使用 .NET Core,并且有一个 build 和一个 clean 任务,如下所示:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "process",
            "command": "dotnet",
            "args": [
                "build",
                "MyProj.csproj"
            ],
            "options": {
                "cwd": "${workspaceFolder}/src/MyProj/"
            },
            "problemMatcher": "$msCompile"
        },
        {
            "label": "clean",
            "type": "shell",
            "linux": {
                "command": "rm",
                "args": [
                    "-rfv",
                    "bin/*",
                    "obj/*"
                ]
            },
            "windows": {
                "command": "del",
                "args": [
                    "/S /Q",
                    "bin/*",
                    "obj/*"
                ]
            },
            "options": {
                "cwd": "${workspaceFolder}/src/MyProj/"
            },
            "problemMatcher": []
        }
    ]
}

这两项任务都按预期工作。

关于javascript - Visual Studio 代码清理任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44671002/

相关文章:

linux - centOS 和 Virtualbox 中的内存增加

typescript - TypeScript const 断言和声明之间有什么区别?

javascript - 传单自定义图层控件

javascript - 搜索词与其余代码分开了吗?

javascript - Ember 入门

linux - Arduino 无法从串口读取

linux - RCP P2 在多用户环境中从只读安装更新

Typescript - 带参数的箭头函数

javascript - 如何修复 Angular Material Components 的构建错误?

javascript - 使用 CSS3 调整大小属性拆分 Pane