mirror of
https://github.com/actions/setup-dotnet.git
synced 2025-08-18 14:45:09 +00:00
Refactor code
This commit is contained in:
parent
cf1d9cb755
commit
1a2e6296c5
2
dist/index.js
vendored
2
dist/index.js
vendored
@ -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;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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.`
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user