| 25 | } |
| 26 | |
| 27 | checkModuleVersionScript(moduleName: string, version: string) { |
| 28 | const command: string = `Get-Module -Name ${moduleName} -ListAvailable | Where-Object Version -match ${version}`; |
| 29 | this.script += `try { |
| 30 | $ErrorActionPreference = "Stop" |
| 31 | $WarningPreference = "SilentlyContinue" |
| 32 | $output = @{} |
| 33 | $data = ${command} |
| 34 | $output['${Constants.versionExists}'] = [string]::IsNullOrEmpty($data) |
| 35 | $output['${Constants.Success}'] = "true" |
| 36 | } |
| 37 | catch { |
| 38 | $output['${Constants.Error}'] = $_.exception.Message |
| 39 | } |
| 40 | return ConvertTo-Json $output`; |
| 41 | core.debug(`CheckModuleVersionScript: ${this.script}`); |
| 42 | return this.script; |
| 43 | } |
| 44 | |
| 45 | getInlineScriptFile(inlineScript: string, errorActionPreference: string) { |
| 46 | this.script = `$ErrorActionPreference = '${errorActionPreference}'${os.EOL}${inlineScript}` |