Resources/Editor/VSCode/tasks.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${relativeFile}: the current opened file relative to workspaceRoot
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
// If you are using InvokeBuild you can enhance this tasks.json using the New-VSCodeTask command:
// Install-Script New-VSCodeTask
// New-VSCodeTask.ps1 -BuildFile .\src\YourModuleName.build.ps1
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
 
    // Start PowerShell
    "windows": {
        "options": {
            "shell": {
                //"executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
                // "executable": "C:\\Program Files\\PowerShell\\6\\pwsh.exe",
                "executable": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
                "args": [ "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command" ]
            }
        }
    },
    "linux": {
        "options": {
            "shell": {
                "executable": "/usr/bin/pwsh",
                "args": [ "-NoProfile", "-Command" ]
            }
        }
    },
    "osx": {
        "options": {
            "shell": {
                "executable": "/usr/local/bin/pwsh",
                "args": [ "-NoProfile", "-Command" ]
            }
        }
    },
 
    // Associate with test task runner
    "tasks": [
        {
            "label": "PesterTest",
            "type": "shell",
            "group": {
                "kind": "test",
                "isDefault": true
            },
            "problemMatcher": [ "$pester" ],
            "command": "Invoke-Pester '${workspaceFolder}/src/Tests/Unit' -PesterOption @{IncludeVSCodeMarker=$true}",
        },
        {
            "label": ".",
            "type": "shell",
            "problemMatcher": "$msCompile",
            "command": "$PSVersionTable;Invoke-Build -Task . -File '${workspaceFolder}/src/<%=$PLASTER_PARAM_ModuleName%>.build.ps1'",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },
        {
            "label": "TestLocal",
            "type": "shell",
            "problemMatcher": "$msCompile",
            "command": "Invoke-Build -Task TestLocal -File '${workspaceFolder}/src/<%=$PLASTER_PARAM_ModuleName%>.build.ps1'"
        },
        {
            "label": "HelpLocal",
            "type": "shell",
            "problemMatcher": "$msCompile",
            "command": "Invoke-Build -Task HelpLocal -File '${workspaceFolder}/src/<%=$PLASTER_PARAM_ModuleName%>.build.ps1'"
        },
        {
            "label": "Clean",
            "type": "shell",
            "problemMatcher": "$msCompile",
            "command": "Invoke-Build -Task Clean -File '${workspaceFolder}/src/<%=$PLASTER_PARAM_ModuleName%>.build.ps1'"
        },
        {
            "label": "ValidateRequirements",
            "type": "shell",
            "problemMatcher": "$msCompile",
            "command": "Invoke-Build -Task ValidateRequirements -File '${workspaceFolder}/src/<%=$PLASTER_PARAM_ModuleName%>.build.ps1'"
        },
        {
            "label": "Analyze",
            "type": "shell",
            "problemMatcher": "$msCompile",
            "command": "Invoke-Build -Task Analyze -File '${workspaceFolder}/src/<%=$PLASTER_PARAM_ModuleName%>.build.ps1'"
        },
        {
            "label": "AnalyzeTests",
            "type": "shell",
            "problemMatcher": "$msCompile",
            "command": "Invoke-Build -Task AnalyzeTests -File '${workspaceFolder}/src/<%=$PLASTER_PARAM_ModuleName%>.build.ps1'"
        },
        {
            "label": "FormattingCheck",
            "type": "shell",
            "problemMatcher": "$msCompile",
            "command": "Invoke-Build -Task FormattingCheck -File '${workspaceFolder}/src/<%=$PLASTER_PARAM_ModuleName%>.build.ps1'"
        },
        {
            "label": "Test",
            "type": "shell",
            "problemMatcher": "$msCompile",
            "command": "Invoke-Build -Task Test -File '${workspaceFolder}/src/<%=$PLASTER_PARAM_ModuleName%>.build.ps1'"
        },
        {
            "label": "DevCC",
            "type": "shell",
            "problemMatcher": "$msCompile",
            "command": "Invoke-Build -Task DevCC -File '${workspaceFolder}/src/<%=$PLASTER_PARAM_ModuleName%>.build.ps1'"
        },
        {
            "label": "Build",
            "type": "shell",
            "problemMatcher": "$msCompile",
            "command": "Invoke-Build -Task Build -File '${workspaceFolder}/src/<%=$PLASTER_PARAM_ModuleName%>.build.ps1'"
        },
        {
            "label": "BuildNoInfra",
            "type": "shell",
            "problemMatcher": "$msCompile",
            "command": "Invoke-Build -Task BuildNoInfra -File '${workspaceFolder}/src/${workspaceFolderBasename}.build.ps1'"
        },
        {
            "label": "InfraTest",
            "type": "shell",
            "problemMatcher": "$msCompile",
            "command": "Invoke-Build -Task InfraTest -File '${workspaceFolder}/src/<%=$PLASTER_PARAM_ModuleName%>.build.ps1'"
        },
        {
            "label": "Pester-Single-Coverage",
            "type": "shell",
            "command": "Import-Module -Name '${workspaceFolder}/src/${workspaceFolderBasename}/${workspaceFolderBasename}.psm1';Invoke-Pester '${workspaceFolder}/src/Tests/Unit/${input:functionName}.Tests.ps1' -CodeCoverage '${workspaceFolder}/src/${workspaceFolderBasename}/*/${input:functionName}.ps1'",
            "problemMatcher": []
        },
        {
            "label": "Pester-Single-Detailed",
            "type": "shell",
            "command": "Import-Module -Name '${workspaceFolder}/src/${workspaceFolderBasename}/${workspaceFolderBasename}.psm1';Invoke-Pester '${workspaceFolder}/src/Tests/Unit/${input:functionName}.Tests.ps1' -Output Detailed",
            "problemMatcher": []
        },
        {
            "label": "DevCC-Single",
            "type": "shell",
            "problemMatcher": "$msCompile",
            "command": "Import-Module -Name '${workspaceFolder}/src/${workspaceFolderBasename}/${workspaceFolderBasename}.psm1';Invoke-Pester '${workspaceFolder}/src/Tests/Unit/${input:functionName}.Tests.ps1' -CodeCoverage '${workspaceFolder}/src/${workspaceFolderBasename}/*/${input:functionName}.ps1' -CodeCoverageOutputFile '${workspaceFolder}/cov.xml'"
        }
    ],
    "inputs": [
        {
            "type": "promptString",
            "id": "functionName",
            "description": "Name of PowerShell function you want to test"
        }
    ]
}