mirror of
https://github.com/azure/login.git
synced 2026-03-15 09:20:56 -04:00
Code refactor
This commit is contained in:
20
src/PowerShell/Utilities/PowerShellToolRunner.ts
Normal file
20
src/PowerShell/Utilities/PowerShellToolRunner.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import * as io from '@actions/io';
|
||||
import * as exec from '@actions/exec';
|
||||
|
||||
export default class PowerShellToolRunner {
|
||||
static psPath: string;
|
||||
|
||||
static async init() {
|
||||
if(!PowerShellToolRunner.psPath) {
|
||||
PowerShellToolRunner.psPath = await io.which("pwsh", true);
|
||||
}
|
||||
}
|
||||
|
||||
static async executePowerShellCommand(command: string, options: any = {}) {
|
||||
try {
|
||||
await exec.exec(`"${PowerShellToolRunner.psPath}" -Command "${command}"`, [], options);
|
||||
} catch(error) {
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user