Code refactor

This commit is contained in:
Akshaya M
2020-03-16 15:15:59 +05:30
parent 1c43646e3a
commit 3e94d97948
8 changed files with 151 additions and 78 deletions

View 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);
}
}
}