@@ -5,6 +5,15 @@ import ScriptBuilder from './ScriptBuilder';
55import PowerShellToolRunner from './PowerShellToolRunner' ;
66
77export default class Utils {
8+ /**
9+ * Add the folder path where Az modules are present to PSModulePath based on runner
10+ *
11+ * @param azPSVersion
12+ *
13+ * If azPSVersion is empty, folder path in which all Az modules are present are set
14+ * If azPSVersion is not empty, folder path of exact Az module version is set
15+ *
16+ */
817 static setPSModulePath ( azPSVersion : string = "" ) {
918 let modulePath : string = "" ;
1019 const runner : string = process . env . RUNNER_OS || os . type ( ) ;
@@ -37,11 +46,11 @@ export default class Utils {
3746 await PowerShellToolRunner . init ( ) ;
3847 await PowerShellToolRunner . executePowerShellScriptBlock ( new ScriptBuilder ( )
3948 . getLatestModuleScript ( moduleName ) , options ) ;
40- const outputJson = JSON . parse ( output . trim ( ) ) ;
41- if ( ! ( Constants . Success in outputJson ) ) {
42- throw new Error ( outputJson [ Constants . Error ] ) ;
49+ const result = JSON . parse ( output . trim ( ) ) ;
50+ if ( ! ( Constants . Success in result ) ) {
51+ throw new Error ( result [ Constants . Error ] ) ;
4352 }
44- const azLatestVersion : string = outputJson [ Constants . AzVersion ] ;
53+ const azLatestVersion : string = result [ Constants . AzVersion ] ;
4554 if ( ! Utils . isValidVersion ( azLatestVersion ) ) {
4655 throw new Error ( `Invalid AzPSVersion: ${ azLatestVersion } ` ) ;
4756 }
0 commit comments