From 3dfe2673ebda42a6c89c6d15e77c93263aafbb5d Mon Sep 17 00:00:00 2001 From: Nikolai Laevskii Date: Wed, 24 May 2023 15:22:01 +0200 Subject: [PATCH] Format: Refactor installer --- __tests__/installer.test.ts | 2 +- src/installer.ts | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/__tests__/installer.test.ts b/__tests__/installer.test.ts index becedea..5e577c9 100644 --- a/__tests__/installer.test.ts +++ b/__tests__/installer.test.ts @@ -117,7 +117,7 @@ describe('DotnetCoreInstaller tests', () => { it('Throws if no location contains correct dotnet version', async () => { await expect(async () => { - await getDotnet('1000.0.0') + await getDotnet('1000.0.0'); }).rejects.toThrow(); }, 30000); diff --git a/src/installer.ts b/src/installer.ts index 31b3532..5389ae8 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -121,7 +121,7 @@ export class DotnetInstallScript { this.escapedScript = path .join(__dirname, '..', 'externals', this.scriptName) .replace(/'/g, "''"); - + this.scriptReady = IS_WINDOWS ? this.setupScriptPowershell() : this.setupScriptBash(); @@ -148,7 +148,8 @@ export class DotnetInstallScript { this.scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`); } - this.scriptPath = (await io.which('pwsh', false)) || (await io.which('powershell', true)); + this.scriptPath = + (await io.which('pwsh', false)) || (await io.which('powershell', true)); } private async setupScriptBash() { @@ -194,8 +195,8 @@ export class DotnetInstallScript { return exec.getExecOutput( `"${this.scriptPath}"`, this.scriptArguments, - getExecOutputOptions, - ) + getExecOutputOptions + ); } } @@ -204,11 +205,13 @@ export abstract class DotnetInstallDir { linux: '/usr/share/dotnet', mac: path.join(process.env['HOME'] + '', '.dotnet'), windows: path.join(process.env['PROGRAMFILES'] + '', 'dotnet') - } + }; public static readonly path = process.env['DOTNET_INSTALL_DIR'] - ? DotnetInstallDir.convertInstallPathToAbsolute(process.env['DOTNET_INSTALL_DIR']) - : DotnetInstallDir.default[getPlatform()] + ? DotnetInstallDir.convertInstallPathToAbsolute( + process.env['DOTNET_INSTALL_DIR'] + ) + : DotnetInstallDir.default[getPlatform()]; private static convertInstallPathToAbsolute(installDir: string): string { let transformedPath; @@ -239,14 +242,16 @@ export class DotnetCoreInstaller { DotnetInstallDir.initialize; } - constructor(private version: string, private quality: QualityOptions) {}; + constructor(private version: string, private quality: QualityOptions) {} public async installDotnet(): Promise { const versionResolver = new DotnetVersionResolver(this.version); const dotnetVersion = await versionResolver.createDotnetVersion(); const installScript = new DotnetInstallScript() - .useArguments(IS_WINDOWS ? '-SkipNonVersionedFiles' : '--skip-non-versioned-files') + .useArguments( + IS_WINDOWS ? '-SkipNonVersionedFiles' : '--skip-non-versioned-files' + ) .useVersion(dotnetVersion, this.quality); const {exitCode, stderr} = await installScript.execute();