diff --git a/lib/cleanup/index.js b/lib/cleanup/index.js index 714f013c0..71ed34750 100644 --- a/lib/cleanup/index.js +++ b/lib/cleanup/index.js @@ -4241,8 +4241,11 @@ function cleanup() { } } catch (error) { - core.warning(`Login cleanup failed with ${error}. Cleanup will be skipped.`); - core.debug(error.stack); + const errorMessage = error instanceof Error ? error.message : String(error); + core.warning(`Login cleanup failed with ${errorMessage}. Cleanup will be skipped.`); + if (error instanceof Error && error.stack) { + core.debug(error.stack); + } } }); } diff --git a/lib/main/index.js b/lib/main/index.js index 53710c157..d4b2ae6c6 100644 --- a/lib/main/index.js +++ b/lib/main/index.js @@ -4770,7 +4770,7 @@ function main() { try { (0, Utils_1.setUserAgent)(); const preCleanup = process.env.AZURE_LOGIN_PRE_CLEANUP; - if ('true' == preCleanup) { + if ('true' === preCleanup) { yield (0, Utils_1.cleanupAzCLIAccounts)(); if (core.getInput('enable-AzPSSession').toLowerCase() === "true") { yield (0, Utils_1.cleanupAzPSAccounts)(); @@ -4790,8 +4790,11 @@ function main() { } } catch (error) { - core.setFailed(`Login failed with ${error}. Double check if the 'auth-type' is correct. Refer to https://github.com/Azure/login#readme for more information.`); - core.debug(error.stack); + const errorMessage = error instanceof Error ? error.message : String(error); + core.setFailed(`Login failed with ${errorMessage}. Double check if the 'auth-type' is correct. Refer to https://github.com/Azure/login#readme for more information.`); + if (error instanceof Error && error.stack) { + core.debug(error.stack); + } } }); } diff --git a/src/Cli/AzureCliLogin.ts b/src/Cli/AzureCliLogin.ts index e762213f8..60290a90d 100644 --- a/src/Cli/AzureCliLogin.ts +++ b/src/Cli/AzureCliLogin.ts @@ -21,7 +21,7 @@ export class AzureCliLogin { core.debug(`Azure CLI path: ${this.azPath}`); let output: string = ""; - const execOptions: any = { + const execOptions: ExecOptions = { listeners: { stdout: (data: Buffer) => { output += data.toString(); @@ -161,7 +161,7 @@ export class AzureCliLogin { async executeAzCliCommand( args: string[], silent?: boolean, - execOptions: any = {}) { + execOptions: ExecOptions = {}) { execOptions.silent = !!silent; await exec.exec(`"${this.azPath}"`, args, execOptions); } diff --git a/src/PowerShell/AzPSUtils.ts b/src/PowerShell/AzPSUtils.ts index 4b287cfd7..5ef4644cc 100644 --- a/src/PowerShell/AzPSUtils.ts +++ b/src/PowerShell/AzPSUtils.ts @@ -2,6 +2,7 @@ import * as core from '@actions/core'; import * as os from 'os'; import * as path from 'path'; import * as exec from '@actions/exec'; +import { ExecOptions } from '@actions/exec/lib/interfaces'; import * as io from '@actions/io'; import AzPSScriptBuilder from './AzPSScriptBuilder'; @@ -54,7 +55,7 @@ export class AzPSUtils { static async runPSScript(psScript: string): Promise { let outputString: string = ""; let commandStdErr = false; - const options: any = { + const options: ExecOptions = { silent: true, listeners: { stdout: (data: Buffer) => { diff --git a/src/cleanup.ts b/src/cleanup.ts index d307920d2..0272751fe 100644 --- a/src/cleanup.ts +++ b/src/cleanup.ts @@ -10,8 +10,11 @@ async function cleanup() { } } catch (error) { - core.warning(`Login cleanup failed with ${error}. Cleanup will be skipped.`); - core.debug(error.stack); + const errorMessage = error instanceof Error ? error.message : String(error); + core.warning(`Login cleanup failed with ${errorMessage}. Cleanup will be skipped.`); + if (error instanceof Error && error.stack) { + core.debug(error.stack); + } } } diff --git a/src/main.ts b/src/main.ts index add837a9e..cd88eca1c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,7 +8,7 @@ async function main() { try { setUserAgent(); const preCleanup: string = process.env.AZURE_LOGIN_PRE_CLEANUP; - if ('true' == preCleanup) { + if ('true' === preCleanup) { await cleanupAzCLIAccounts(); if (core.getInput('enable-AzPSSession').toLowerCase() === "true") { await cleanupAzPSAccounts(); @@ -31,8 +31,11 @@ async function main() { } } catch (error) { - core.setFailed(`Login failed with ${error}. Double check if the 'auth-type' is correct. Refer to https://github.com/Azure/login#readme for more information.`); - core.debug(error.stack); + const errorMessage = error instanceof Error ? error.message : String(error); + core.setFailed(`Login failed with ${errorMessage}. Double check if the 'auth-type' is correct. Refer to https://github.com/Azure/login#readme for more information.`); + if (error instanceof Error && error.stack) { + core.debug(error.stack); + } } }