From 44ac234a2e43e4d1792d7576d4afef6b03acf2d2 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Thu, 18 Aug 2022 10:51:53 +0200 Subject: [PATCH] Add static fields to DotnetCoreInstaller --- dist/index.js | 10 +++++----- src/installer.ts | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/dist/index.js b/dist/index.js index 8c119b2..8d79a6c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -253,8 +253,6 @@ class DotnetCoreInstaller { return __awaiter(this, void 0, void 0, function* () { let output = ''; let resultCode = 0; - const installationDirectoryWindows = 'C:\\Program` Files\\dotnet'; - const installationDirectoryLinux = '/usr/share/dotnet'; const versionResolver = new DotnetVersionResolver(this.version); const versionObject = versionResolver.createVersionObject(); var envVariables = {}; @@ -284,7 +282,7 @@ class DotnetCoreInstaller { if (process.env['no_proxy'] != null) { command += ` -ProxyBypassList ${process.env['no_proxy']}`; } - command += ` -InstallDir ${installationDirectoryWindows}`; + command += ` -InstallDir ${DotnetCoreInstaller.installationDirectoryWindows}`; // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used const powershellPath = yield io.which('powershell', true); var options = { @@ -322,7 +320,7 @@ class DotnetCoreInstaller { } } if (IS_LINUX) { - scriptArguments.push('--install-dir', installationDirectoryLinux); + scriptArguments.push('--install-dir', DotnetCoreInstaller.installationDirectoryLinux); } // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used resultCode = yield exec.exec(`"${scriptPath}"`, scriptArguments, { @@ -347,7 +345,7 @@ class DotnetCoreInstaller { else { if (IS_WINDOWS) { // This is the default set in install-dotnet.ps1 - core.exportVariable('DOTNET_ROOT', "C:\Program Files\dotnet"); + core.exportVariable('DOTNET_ROOT', DotnetCoreInstaller.installationDirectoryWindows); } else { // This is the default set in install-dotnet.sh @@ -359,6 +357,8 @@ class DotnetCoreInstaller { } } exports.DotnetCoreInstaller = DotnetCoreInstaller; +DotnetCoreInstaller.installationDirectoryWindows = 'C:\\Program` Files\\dotnet'; +DotnetCoreInstaller.installationDirectoryLinux = '/usr/share/dotnet'; function logWarning(message) { const warningPrefix = '[warning]'; core.info(`${warningPrefix}${message}`); diff --git a/src/installer.ts b/src/installer.ts index 9de53f9..c2b4486 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -83,6 +83,8 @@ export class DotnetVersionResolver { export class DotnetCoreInstaller { private version: string; private quality: string; + static installationDirectoryWindows = 'C:\\Program` Files\\dotnet'; + static installationDirectoryLinux = '/usr/share/dotnet'; constructor(version: string, quality: string) { this.version = version; @@ -92,8 +94,7 @@ export class DotnetCoreInstaller { public async installDotnet() { let output = ''; let resultCode = 0; - const installationDirectoryWindows = 'C:\\Program` Files\\dotnet'; - const installationDirectoryLinux = '/usr/share/dotnet'; + const versionResolver = new DotnetVersionResolver(this.version); const versionObject = versionResolver.createVersionObject(); @@ -129,7 +130,7 @@ export class DotnetCoreInstaller { command += ` -ProxyBypassList ${process.env['no_proxy']}`; } - command += ` -InstallDir ${installationDirectoryWindows}`; + command += ` -InstallDir ${DotnetCoreInstaller.installationDirectoryWindows}`; // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used const powershellPath = await io.which('powershell', true); @@ -178,7 +179,7 @@ export class DotnetCoreInstaller { } if (IS_LINUX) { - scriptArguments.push('--install-dir', installationDirectoryLinux); + scriptArguments.push('--install-dir', DotnetCoreInstaller.installationDirectoryLinux); } // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used @@ -206,7 +207,7 @@ export class DotnetCoreInstaller { // This is the default set in install-dotnet.ps1 core.exportVariable( 'DOTNET_ROOT', - "C:\Program Files\dotnet" + DotnetCoreInstaller.installationDirectoryWindows ); } else { // This is the default set in install-dotnet.sh