Skip to content

Commit

Permalink
Eliminate hard dependency on version resolver in installer
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolai-laevskii committed Sep 4, 2023
1 parent 9191e7e commit d903b61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
11 changes: 2 additions & 9 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,18 +274,11 @@ export class DotnetCoreInstaller {
}

constructor(
private version: string,
private dotnetVersion: DotnetVersion,
private quality: QualityOptions,
private preferInstalled = false
) {}

public async installDotnet(): Promise<string | null> {
const versionResolver = new DotnetVersionResolver(
this.version,
this.preferInstalled
);
const dotnetVersion = await versionResolver.createDotnetVersion();

/**
* Install dotnet runitme first in order to get
* the latest stable version of dotnet CLI
Expand Down Expand Up @@ -321,7 +314,7 @@ export class DotnetCoreInstaller {
IS_WINDOWS ? '-SkipNonVersionedFiles' : '--skip-non-versioned-files'
)
// Use version provided by user
.useVersion(dotnetVersion, this.quality)
.useVersion(this.dotnetVersion, this.quality)
.execute();

if (dotnetInstallOutput.exitCode) {
Expand Down
8 changes: 5 additions & 3 deletions src/setup-dotnet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as core from '@actions/core';
import {DotnetCoreInstaller, DotnetInstallDir} from './installer';
import {DotnetCoreInstaller, DotnetInstallDir, DotnetVersionResolver} from './installer';
import * as fs from 'fs';
import path from 'path';
import semver from 'semver';
Expand Down Expand Up @@ -68,12 +68,14 @@ export async function run() {
}

let dotnetInstaller: DotnetCoreInstaller;
let dotnetVersionResolver: DotnetVersionResolver;

const uniqueVersions = new Set<string>(versions);
for (const version of uniqueVersions) {
dotnetVersionResolver = new DotnetVersionResolver(version, preferInstalled);
dotnetInstaller = new DotnetCoreInstaller(
version,
await dotnetVersionResolver.createDotnetVersion(),
quality,
preferInstalled
);
const installedVersion = await dotnetInstaller.installDotnet();
installedDotnetVersions.push(installedVersion);
Expand Down

0 comments on commit d903b61

Please sign in to comment.