mirror of
https://github.com/actions/setup-dotnet.git
synced 2024-11-22 19:41:08 +07:00
Format: Refactor installer
This commit is contained in:
parent
aa85432603
commit
3dfe2673eb
@ -117,7 +117,7 @@ describe('DotnetCoreInstaller tests', () => {
|
|||||||
|
|
||||||
it('Throws if no location contains correct dotnet version', async () => {
|
it('Throws if no location contains correct dotnet version', async () => {
|
||||||
await expect(async () => {
|
await expect(async () => {
|
||||||
await getDotnet('1000.0.0')
|
await getDotnet('1000.0.0');
|
||||||
}).rejects.toThrow();
|
}).rejects.toThrow();
|
||||||
}, 30000);
|
}, 30000);
|
||||||
|
|
||||||
|
@ -148,7 +148,8 @@ export class DotnetInstallScript {
|
|||||||
this.scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`);
|
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() {
|
private async setupScriptBash() {
|
||||||
@ -194,8 +195,8 @@ export class DotnetInstallScript {
|
|||||||
return exec.getExecOutput(
|
return exec.getExecOutput(
|
||||||
`"${this.scriptPath}"`,
|
`"${this.scriptPath}"`,
|
||||||
this.scriptArguments,
|
this.scriptArguments,
|
||||||
getExecOutputOptions,
|
getExecOutputOptions
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,11 +205,13 @@ export abstract class DotnetInstallDir {
|
|||||||
linux: '/usr/share/dotnet',
|
linux: '/usr/share/dotnet',
|
||||||
mac: path.join(process.env['HOME'] + '', '.dotnet'),
|
mac: path.join(process.env['HOME'] + '', '.dotnet'),
|
||||||
windows: path.join(process.env['PROGRAMFILES'] + '', 'dotnet')
|
windows: path.join(process.env['PROGRAMFILES'] + '', 'dotnet')
|
||||||
}
|
};
|
||||||
|
|
||||||
public static readonly path = process.env['DOTNET_INSTALL_DIR']
|
public static readonly path = process.env['DOTNET_INSTALL_DIR']
|
||||||
? DotnetInstallDir.convertInstallPathToAbsolute(process.env['DOTNET_INSTALL_DIR'])
|
? DotnetInstallDir.convertInstallPathToAbsolute(
|
||||||
: DotnetInstallDir.default[getPlatform()]
|
process.env['DOTNET_INSTALL_DIR']
|
||||||
|
)
|
||||||
|
: DotnetInstallDir.default[getPlatform()];
|
||||||
|
|
||||||
private static convertInstallPathToAbsolute(installDir: string): string {
|
private static convertInstallPathToAbsolute(installDir: string): string {
|
||||||
let transformedPath;
|
let transformedPath;
|
||||||
@ -239,14 +242,16 @@ export class DotnetCoreInstaller {
|
|||||||
DotnetInstallDir.initialize;
|
DotnetInstallDir.initialize;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(private version: string, private quality: QualityOptions) {};
|
constructor(private version: string, private quality: QualityOptions) {}
|
||||||
|
|
||||||
public async installDotnet(): Promise<string> {
|
public async installDotnet(): Promise<string> {
|
||||||
const versionResolver = new DotnetVersionResolver(this.version);
|
const versionResolver = new DotnetVersionResolver(this.version);
|
||||||
const dotnetVersion = await versionResolver.createDotnetVersion();
|
const dotnetVersion = await versionResolver.createDotnetVersion();
|
||||||
|
|
||||||
const installScript = new DotnetInstallScript()
|
const installScript = new DotnetInstallScript()
|
||||||
.useArguments(IS_WINDOWS ? '-SkipNonVersionedFiles' : '--skip-non-versioned-files')
|
.useArguments(
|
||||||
|
IS_WINDOWS ? '-SkipNonVersionedFiles' : '--skip-non-versioned-files'
|
||||||
|
)
|
||||||
.useVersion(dotnetVersion, this.quality);
|
.useVersion(dotnetVersion, this.quality);
|
||||||
|
|
||||||
const {exitCode, stderr} = await installScript.execute();
|
const {exitCode, stderr} = await installScript.execute();
|
||||||
|
Loading…
Reference in New Issue
Block a user