Refactor code

This commit is contained in:
IvanZosimov 2022-09-22 16:28:22 +02:00
parent cf1d9cb755
commit 1a2e6296c5
3 changed files with 6 additions and 5 deletions

2
dist/index.js vendored
View File

@ -447,7 +447,7 @@ function run() {
} }
if (versions.length) { if (versions.length) {
const quality = core.getInput('dotnet-quality'); const quality = core.getInput('dotnet-quality');
if (quality && !qualityOptions.includes(quality)) { if (!qualityOptions.includes(quality)) {
throw new Error(`${quality} is not a supported value for 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.`); throw new Error(`${quality} is not a supported value for 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.`);
} }
let dotnetInstaller; let dotnetInstaller;

View File

@ -7,6 +7,7 @@ import {chmodSync} from 'fs';
import path from 'path'; import path from 'path';
import semver from 'semver'; import semver from 'semver';
import {IS_LINUX, IS_WINDOWS} from './utils'; import {IS_LINUX, IS_WINDOWS} from './utils';
import {QualityOptions} from './setup-dotnet';
export interface DotnetVersion { export interface DotnetVersion {
type: string; type: string;
@ -111,7 +112,7 @@ export class DotnetVersionResolver {
export class DotnetCoreInstaller { export class DotnetCoreInstaller {
private version: string; private version: string;
private quality: string; private quality: QualityOptions;
private static readonly installationDirectoryWindows = path.join( private static readonly installationDirectoryWindows = path.join(
process.env['PROGRAMFILES'] + '', process.env['PROGRAMFILES'] + '',
'dotnet' 'dotnet'
@ -146,7 +147,7 @@ export class DotnetCoreInstaller {
} }
} }
constructor(version: string, quality: string) { constructor(version: string, quality: QualityOptions) {
this.version = version; this.version = version;
this.quality = quality; this.quality = quality;
} }

View File

@ -12,7 +12,7 @@ const qualityOptions = [
'ga' 'ga'
] as const; ] as const;
type QualityOptions = typeof qualityOptions[number]; export type QualityOptions = typeof qualityOptions[number];
export async function run() { export async function run() {
try { try {
@ -50,7 +50,7 @@ export async function run() {
if (versions.length) { if (versions.length) {
const quality = core.getInput('dotnet-quality') as QualityOptions; const quality = core.getInput('dotnet-quality') as QualityOptions;
if (quality && !qualityOptions.includes(quality)) { if (!qualityOptions.includes(quality)) {
throw new Error( throw new Error(
`${quality} is not a supported value for 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.` `${quality} is not a supported value for 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.`
); );