Skip to content

Commit

Permalink
fix #403
Browse files Browse the repository at this point in the history
  • Loading branch information
MoChilia committed Jan 16, 2024
1 parent 2d38cb8 commit 1e49383
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/Cli/AzureCliLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export class AzureCliLogin {
async login() {
core.info(`Running Azure CLI Login.`);
this.azPath = await io.which("az", true);
if (!this.azPath) {
throw new Error("Azure CLI is not found in the runner.");
}
core.debug(`Azure CLI path: ${this.azPath}`);

let output: string = "";
Expand Down
3 changes: 3 additions & 0 deletions src/PowerShell/AzPSUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export class AzPSUtils {
};

let psPath: string = await io.which(AzPSConstants.PowerShell_CmdName, true);
if (!psPath) {
throw new Error("PowerShell is not found in the runner.");
}
await exec.exec(`"${psPath}"`, ["-Command", psScript], options)
if (commandStdErr) {
throw new Error('Azure PowerShell login failed with errors.');
Expand Down
6 changes: 4 additions & 2 deletions src/common/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export function setUserAgent(): void {
export async function cleanupAzCLIAccounts(): Promise<void> {
let azPath = await io.which("az", true);
if (!azPath) {
throw new Error("Azure CLI is not found in the runner.");
core.warning("Azure CLI is not found in the runner.");
return;
}
core.debug(`Azure CLI path: ${azPath}`);
core.info("Clearing azure cli accounts from the local cache.");
Expand All @@ -24,7 +25,8 @@ export async function cleanupAzCLIAccounts(): Promise<void> {
export async function cleanupAzPSAccounts(): Promise<void> {
let psPath: string = await io.which(AzPSConstants.PowerShell_CmdName, true);
if (!psPath) {
throw new Error("PowerShell is not found in the runner.");
core.warning("PowerShell is not found in the runner.");
return;
}
core.debug(`PowerShell path: ${psPath}`);
core.debug("Importing Azure PowerShell module.");
Expand Down

0 comments on commit 1e49383

Please sign in to comment.