2017-06-21 86 views
0

我正在使用我的Typescript項目的Ubuntu中的Visual Studio代碼。我想知道是否有可能執行某種'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中有一些特殊的env變量語法?

回答

0

我也一直在尋找這個,但據我所知,在tasks.json中不可能有多個任務。你可以有一個任務數組,但只包含同一個任務的不同命令行參數。這個例子有'echo'任務,你可以用不同的參數調用它。如果調用任務「你好」,然後「呼應的Hello World」將被執行:

{ 
    "version": "0.1.0", 
    "command": "echo", 
    "isShellCommand": true, 
    "args": [], 
    "showOutput": "always", 
    "echoCommand": true, 
    "suppressTaskName": true, 
    "tasks": [ 
     { 
      "taskName": "hello", 
      "args": ["Hello World"] 
     }, 
     { 
      "taskName": "bye", 
      "args": ["Good Bye"] 
     } 
    ] 
}