mirror of
https://github.com/actions/setup-dotnet.git
synced 2025-08-24 09:30:22 +00:00
Refactor code
This commit is contained in:
parent
99eb4e7d58
commit
4aad884a7a
21
dist/index.js
vendored
21
dist/index.js
vendored
@ -301,10 +301,6 @@ class DotnetCoreInstaller {
|
||||
}
|
||||
installDotnet() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const dotnetInstallDir = process.env['DOTNET_INSTALL_DIR'];
|
||||
if (dotnetInstallDir) {
|
||||
core.debug(`DOTNET_INSTALL_DIR is set up to ${dotnetInstallDir}`);
|
||||
}
|
||||
const windowsDefaultOptions = [
|
||||
'-NoLogo',
|
||||
'-Sta',
|
||||
@ -337,10 +333,10 @@ class DotnetCoreInstaller {
|
||||
if (process.env['no_proxy'] != null) {
|
||||
scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`);
|
||||
}
|
||||
if (!dotnetInstallDir) {
|
||||
scriptArguments.push('-InstallDir', `'${DotnetCoreInstaller.installationDirectoryWindows}'`);
|
||||
if (!process.env['DOTNET_INSTALL_DIR']) {
|
||||
process.env['DOTNET_INSTALL_DIR'] =
|
||||
DotnetCoreInstaller.installationDirectoryWindows;
|
||||
}
|
||||
// process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
|
||||
scriptPath =
|
||||
(yield io.which('pwsh', false)) || (yield io.which('powershell', true));
|
||||
scriptArguments = windowsDefaultOptions.concat(scriptArguments);
|
||||
@ -355,12 +351,13 @@ class DotnetCoreInstaller {
|
||||
if (this.quality) {
|
||||
this.setQuality(dotnetVersion, scriptArguments);
|
||||
}
|
||||
if (!dotnetInstallDir) {
|
||||
scriptArguments.push('--install-dir', utils_1.IS_LINUX
|
||||
if (!process.env['DOTNET_INSTALL_DIR']) {
|
||||
process.env['DOTNET_INSTALL_DIR'] = utils_1.IS_LINUX
|
||||
? DotnetCoreInstaller.installationDirectoryLinux
|
||||
: DotnetCoreInstaller.installationDirectoryMac);
|
||||
: DotnetCoreInstaller.installationDirectoryMac;
|
||||
}
|
||||
}
|
||||
// process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
|
||||
const getExecOutputOptions = {
|
||||
ignoreReturnCode: true,
|
||||
env: process.env
|
||||
@ -369,9 +366,7 @@ class DotnetCoreInstaller {
|
||||
if (exitCode) {
|
||||
throw new Error(`Failed to install dotnet ${exitCode}. ${stdout}`);
|
||||
}
|
||||
return this.outputDotnetVersion(dotnetVersion.value, dotnetInstallDir
|
||||
? dotnetInstallDir
|
||||
: scriptArguments[scriptArguments.length - 1]);
|
||||
return this.outputDotnetVersion(dotnetVersion.value, process.env['DOTNET_INSTALL_DIR']);
|
||||
});
|
||||
}
|
||||
outputDotnetVersion(version, installationPath) {
|
||||
|
@ -170,10 +170,6 @@ export class DotnetCoreInstaller {
|
||||
}
|
||||
|
||||
public async installDotnet(): Promise<string> {
|
||||
const dotnetInstallDir = process.env['DOTNET_INSTALL_DIR'];
|
||||
if (dotnetInstallDir) {
|
||||
core.debug(`DOTNET_INSTALL_DIR is set up to ${dotnetInstallDir}`);
|
||||
}
|
||||
const windowsDefaultOptions = [
|
||||
'-NoLogo',
|
||||
'-Sta',
|
||||
@ -212,13 +208,11 @@ export class DotnetCoreInstaller {
|
||||
scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`);
|
||||
}
|
||||
|
||||
if (!dotnetInstallDir) {
|
||||
scriptArguments.push(
|
||||
'-InstallDir',
|
||||
`'${DotnetCoreInstaller.installationDirectoryWindows}'`
|
||||
);
|
||||
if (!process.env['DOTNET_INSTALL_DIR']) {
|
||||
process.env['DOTNET_INSTALL_DIR'] =
|
||||
DotnetCoreInstaller.installationDirectoryWindows;
|
||||
}
|
||||
// process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
|
||||
|
||||
scriptPath =
|
||||
(await io.which('pwsh', false)) || (await io.which('powershell', true));
|
||||
scriptArguments = windowsDefaultOptions.concat(scriptArguments);
|
||||
@ -235,16 +229,13 @@ export class DotnetCoreInstaller {
|
||||
this.setQuality(dotnetVersion, scriptArguments);
|
||||
}
|
||||
|
||||
if (!dotnetInstallDir) {
|
||||
scriptArguments.push(
|
||||
'--install-dir',
|
||||
IS_LINUX
|
||||
if (!process.env['DOTNET_INSTALL_DIR']) {
|
||||
process.env['DOTNET_INSTALL_DIR'] = IS_LINUX
|
||||
? DotnetCoreInstaller.installationDirectoryLinux
|
||||
: DotnetCoreInstaller.installationDirectoryMac
|
||||
);
|
||||
: DotnetCoreInstaller.installationDirectoryMac;
|
||||
}
|
||||
}
|
||||
|
||||
// process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used
|
||||
const getExecOutputOptions = {
|
||||
ignoreReturnCode: true,
|
||||
env: process.env as {string: string}
|
||||
@ -260,9 +251,7 @@ export class DotnetCoreInstaller {
|
||||
|
||||
return this.outputDotnetVersion(
|
||||
dotnetVersion.value,
|
||||
dotnetInstallDir
|
||||
? dotnetInstallDir
|
||||
: scriptArguments[scriptArguments.length - 1]
|
||||
process.env['DOTNET_INSTALL_DIR']
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user