MCPcopy Create free account
hub / github.com/Azure/powershell / checkModuleVersion

Method checkModuleVersion

src/Utilities/Utils.ts:100–122  ·  view source on GitHub ↗
(moduleName: string, version: string)

Source from the content-addressed store, hash-verified

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);

Callers 1

importAzModuleMethod · 0.45

Calls 4

toStringMethod · 0.80
isValidVersionMethod · 0.45

Tested by

no test coverage detected