diff --git a/dist/index.js b/dist/index.js index 0e88015..312c5a7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -341,13 +341,14 @@ class DotnetInstallScript { constructor() { this.scriptName = utils_1.IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh'; this.scriptArguments = []; - this.scriptPath = ''; this.escapedScript = path_1.default .join(__dirname, '..', 'externals', this.scriptName) .replace(/'/g, "''"); - this.scriptReady = utils_1.IS_WINDOWS - ? this.setupScriptPowershell() - : this.setupScriptBash(); + if (utils_1.IS_WINDOWS) { + this.setupScriptPowershell(); + return; + } + this.setupScriptBash(); } setupScriptPowershell() { return __awaiter(this, void 0, void 0, function* () { @@ -368,14 +369,19 @@ class DotnetInstallScript { if (process.env['no_proxy'] != null) { this.scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`); } - this.scriptPath = - (yield io.which('pwsh', false)) || (yield io.which('powershell', true)); }); } setupScriptBash() { return __awaiter(this, void 0, void 0, function* () { (0, fs_1.chmodSync)(this.escapedScript, '777'); - this.scriptPath = yield io.which(this.escapedScript, true); + }); + } + getScriptPath() { + return __awaiter(this, void 0, void 0, function* () { + if (utils_1.IS_WINDOWS) { + return (yield io.which('pwsh', false)) || io.which('powershell', true); + } + return io.which(this.escapedScript, true); }); } useArguments(...args) { @@ -401,8 +407,7 @@ class DotnetInstallScript { ignoreReturnCode: true, env: process.env }; - yield this.scriptReady; - return exec.getExecOutput(`"${this.scriptPath}"`, this.scriptArguments, getExecOutputOptions); + return exec.getExecOutput(`"${yield this.getScriptPath()}"`, this.scriptArguments, getExecOutputOptions); }); } } diff --git a/src/installer.ts b/src/installer.ts index ec46528..7aaffcb 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -129,17 +129,18 @@ export class DotnetInstallScript { private scriptName = IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh'; private escapedScript: string; private scriptArguments: string[] = []; - private scriptPath = ''; - private scriptReady: Promise; constructor() { this.escapedScript = path .join(__dirname, '..', 'externals', this.scriptName) .replace(/'/g, "''"); - this.scriptReady = IS_WINDOWS - ? this.setupScriptPowershell() - : this.setupScriptBash(); + if (IS_WINDOWS) { + this.setupScriptPowershell(); + return; + } + + this.setupScriptBash(); } private async setupScriptPowershell() { @@ -162,14 +163,18 @@ export class DotnetInstallScript { if (process.env['no_proxy'] != null) { this.scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`); } - - this.scriptPath = - (await io.which('pwsh', false)) || (await io.which('powershell', true)); } private async setupScriptBash() { chmodSync(this.escapedScript, '777'); - this.scriptPath = await io.which(this.escapedScript, true); + } + + private async getScriptPath() { + if (IS_WINDOWS) { + return (await io.which('pwsh', false)) || io.which('powershell', true); + } + + return io.which(this.escapedScript, true); } public useArguments(...args: string[]) { @@ -202,10 +207,8 @@ export class DotnetInstallScript { env: process.env as {string: string} }; - await this.scriptReady; - return exec.getExecOutput( - `"${this.scriptPath}"`, + `"${await this.getScriptPath()}"`, this.scriptArguments, getExecOutputOptions );