Support various nuget.config name formats #188
This commit is contained in:
commit
c47e26f841
|
@ -4840,11 +4840,23 @@ const github = __importStar(__webpack_require__(469));
|
||||||
const xmlbuilder = __importStar(__webpack_require__(312));
|
const xmlbuilder = __importStar(__webpack_require__(312));
|
||||||
const xmlParser = __importStar(__webpack_require__(989));
|
const xmlParser = __importStar(__webpack_require__(989));
|
||||||
function configAuthentication(feedUrl, existingFileLocation = '', processRoot = process.cwd()) {
|
function configAuthentication(feedUrl, existingFileLocation = '', processRoot = process.cwd()) {
|
||||||
const existingNuGetConfig = path.resolve(processRoot, existingFileLocation == '' ? 'nuget.config' : existingFileLocation);
|
const existingNuGetConfig = path.resolve(processRoot, existingFileLocation === ''
|
||||||
|
? getExistingNugetConfig(processRoot)
|
||||||
|
: existingFileLocation);
|
||||||
const tempNuGetConfig = path.resolve(processRoot, '../', 'nuget.config');
|
const tempNuGetConfig = path.resolve(processRoot, '../', 'nuget.config');
|
||||||
writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
|
writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
|
||||||
}
|
}
|
||||||
exports.configAuthentication = configAuthentication;
|
exports.configAuthentication = configAuthentication;
|
||||||
|
function getExistingNugetConfig(processRoot) {
|
||||||
|
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, existingFileLocation, tempFileLocation) {
|
function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) {
|
||||||
console.log(`dotnet-auth: Finding any source references in ${existingFileLocation}, writing a new temporary configuration file with credentials to ${tempFileLocation}`);
|
console.log(`dotnet-auth: Finding any source references in ${existingFileLocation}, writing a new temporary configuration file with credentials to ${tempFileLocation}`);
|
||||||
let xml;
|
let xml;
|
||||||
|
|
|
@ -13,7 +13,9 @@ export function configAuthentication(
|
||||||
) {
|
) {
|
||||||
const existingNuGetConfig: string = path.resolve(
|
const existingNuGetConfig: string = path.resolve(
|
||||||
processRoot,
|
processRoot,
|
||||||
existingFileLocation == '' ? 'nuget.config' : existingFileLocation
|
existingFileLocation === ''
|
||||||
|
? getExistingNugetConfig(processRoot)
|
||||||
|
: existingFileLocation
|
||||||
);
|
);
|
||||||
|
|
||||||
const tempNuGetConfig: string = path.resolve(
|
const tempNuGetConfig: string = path.resolve(
|
||||||
|
@ -25,6 +27,17 @@ export function configAuthentication(
|
||||||
writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
|
writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(
|
function writeFeedToFile(
|
||||||
feedUrl: string,
|
feedUrl: string,
|
||||||
existingFileLocation: string,
|
existingFileLocation: string,
|
||||||
|
|
Loading…
Reference in New Issue