Resolve conflicts

This commit is contained in:
Vladimir Safonkin
2021-04-22 14:19:03 +03:00
5 changed files with 58 additions and 22 deletions

View File

@ -13,7 +13,9 @@ export function configAuthentication(
) {
const existingNuGetConfig: string = path.resolve(
processRoot,
existingFileLocation == '' ? 'nuget.config' : existingFileLocation
existingFileLocation === ''
? getExistingNugetConfig(processRoot)
: existingFileLocation
);
const tempNuGetConfig: string = path.resolve(
@ -29,6 +31,17 @@ function isValidKey(key: string): boolean {
return /^[\w\-\.]+$/i.test(key);
}
function getExistingNugetConfig(processRoot: string) {
const defaultConfigName = 'nuget.config';
const configFileNames = fs
.readdirSync(processRoot)
.filter(filename => filename.toLowerCase() === defaultConfigName);
if (configFileNames.length) {
return configFileNames[0];
}
return defaultConfigName;
}
function writeFeedToFile(
feedUrl: string,
existingFileLocation: string,

View File

@ -30,7 +30,7 @@ export class DotNetVersionInfo {
}
//Note: No support for previews when using generic
let parts: string[] = version.split('.');
const parts: string[] = version.split('.');
if (parts.length < 2 || parts.length > 3) this.throwInvalidVersionFormat();
@ -38,8 +38,10 @@ export class DotNetVersionInfo {
this.throwInvalidVersionFormat();
}
let major = this.getVersionNumberOrThrow(parts[0]);
let minor = this.getVersionNumberOrThrow(parts[1]);
const major = this.getVersionNumberOrThrow(parts[0]);
const minor = ['x', '*'].includes(parts[1])
? parts[1]
: this.getVersionNumberOrThrow(parts[1]);
this.fullversion = major + '.' + minor;
}
@ -60,7 +62,9 @@ export class DotNetVersionInfo {
}
private throwInvalidVersionFormat() {
throw 'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*';
throw new Error(
'Invalid version format! Supported: 1.2.3, 1.2, 1.2.x, 1.2.*'
);
}
/**
@ -187,7 +191,7 @@ export class DotnetCoreInstaller {
console.log(process.env['PATH']);
if (resultCode != 0) {
throw `Failed to install dotnet ${resultCode}. ${output}`;
throw new Error(`Failed to install dotnet ${resultCode}. ${output}`);
}
}
@ -236,7 +240,9 @@ export class DotnetCoreInstaller {
);
if (releasesInfo.length == 0) {
throw `Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`;
throw new Error(
`Could not find dotnet core version. Please ensure that specified version ${versionInfo.inputVersion} is valid.`
);
}
let release = releasesInfo[0];
@ -264,9 +270,11 @@ export class DotnetCoreInstaller {
});
if (releasesInfo.length === 0) {
throw `Could not find info for version ${versionParts.join(
'.'
)} at ${DotNetCoreIndexUrl}`;
throw new Error(
`Could not find info for version ${versionParts.join(
'.'
)} at ${DotNetCoreIndexUrl}`
);
}
return releasesInfo[0]['releases.json'];