Skip to content

Commit 9695107

Browse files
committed
Add support for specifying which version of pester to install
1 parent 85940be commit 9695107

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

Extension/src/pester.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ export async function run() {
1919
let CodeCoverageOutputFile = tl.getInput("CodeCoverageOutputFile");
2020
let CodeCoverageFolder = tl.getInput("CodeCoverageFolder");
2121
let ScriptBlock = tl.getInput("ScriptBlock");
22+
let PesterVersion = tl.getInput("PesterVersion");
23+
24+
let TargetPesterVersion = "0.0.0";
25+
if (PesterVersion === "OtherVersion") {
26+
TargetPesterVersion = tl.getInput("TargetPesterVersion");
27+
if (!TargetPesterVersion.match(/\d+\.\d+\.\d+/g)) {
28+
logError(`Invalid version number provided for Pester. Please ensure it is in the format x.y.z`);
29+
}
30+
}
2231

2332
// we need to get the verbose flag passed in as script flag
2433
var verbose = (tl.getVariable("System.Debug") === "true");
@@ -75,6 +84,11 @@ export async function run() {
7584
args.push("-Verbose");
7685
}
7786

87+
if (TargetPesterVersion !== "0.0.0") {
88+
args.push("-PesterVersion");
89+
args.push(TargetPesterVersion);
90+
}
91+
7892
logInfo(`${executable} ${args.join(" ")}`);
7993

8094
var spawn = require("child_process").spawn, child;
@@ -94,4 +108,4 @@ export async function run() {
94108
}
95109
}
96110

97-
run();
111+
run();

Extension/task/task.json

+26
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,32 @@
109109
"groupName": "advanced",
110110
"visibleRule": "usePSCore = False"
111111
},
112+
{
113+
"name": "PesterVersion",
114+
"type": "radio",
115+
"label": "Pester Version",
116+
"defaultValue": "LatestVersion",
117+
"required": false,
118+
"options": {
119+
"LatestVersion": "Latest Available version",
120+
"OtherVersion": "Specify other version"
121+
},
122+
"groupName": "advanced",
123+
"helpMarkDown": "Choose which version of Pester to use for your tests, the version specified will be downloaded from an available PS Gallery. If no gallery is available then it will fall back to the version shipped with the task, currently 4.10.1"
124+
},
125+
{
126+
"name": "TargetPesterVersion",
127+
"aliases": [
128+
"preferredPesterVersion"
129+
],
130+
"type": "string",
131+
"label": "Preferred Pester PowerShell Version",
132+
"defaultValue": "",
133+
"required": true,
134+
"visibleRule": "PesterVersion = OtherVersion",
135+
"groupName": "advanced",
136+
"helpMarkDown": "Speicify version of Pester to install if not latest. This will download it from whichever PS Gallery has it available. If it's not available then the task will fail."
137+
},
112138
{
113139
"name": "ScriptBlock",
114140
"type": "string",

0 commit comments

Comments
 (0)