(moduleName: string, version: string)
| 98 | } |
| 99 | |
| 100 | static async checkModuleVersion(moduleName: string, version: string) { |
| 101 | let output: string = ""; |
| 102 | const options: any = { |
| 103 | listeners: { |
| 104 | stdout: (data: Buffer) => { |
| 105 | output += data.toString(); |
| 106 | } |
| 107 | } |
| 108 | }; |
| 109 | if (!Utils.isValidVersion(output.trim())) { |
| 110 | return ""; |
| 111 | } |
| 112 | await PowerShellToolRunner.executePowerShellCommand(new ScriptBuilder() |
| 113 | .checkModuleVersionScript(moduleName, version), options); |
| 114 | const outputJson = JSON.parse(output.trim()); |
| 115 | if (!(Constants.Success in outputJson)) { |
| 116 | throw new Error(outputJson[Constants.Error]); |
| 117 | } |
| 118 | const versionExists: boolean = outputJson[Constants.versionExists].toLowerCase() === "true"; |
| 119 | if(!(versionExists)) { |
| 120 | throw new Error("Invalid azPSVersion. Refer https://aka.ms/azure-powershell-release-notes for supported versions."); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | static isValidVersion(version: string): boolean { |
| 125 | return !!version.match(Constants.versionPattern); |
no test coverage detected