Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support various nuget.config name formats #188

Merged
merged 5 commits into from Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion dist/index.js
Expand Up @@ -4840,11 +4840,22 @@ const github = __importStar(__webpack_require__(469));
const xmlbuilder = __importStar(__webpack_require__(312));
const xmlParser = __importStar(__webpack_require__(989));
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');
writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
}
exports.configAuthentication = configAuthentication;
function getExistingNugetConfig(processRoot) {
const configFileNames = fs
.readdirSync(processRoot)
.filter(filename => filename.toLowerCase() == 'nuget.config');
if (configFileNames.length) {
return configFileNames[0];
}
return 'nuget.config';
}
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}`);
let xml;
Expand Down
14 changes: 13 additions & 1 deletion src/authutil.ts
Expand Up @@ -13,7 +13,9 @@ export function configAuthentication(
) {
const existingNuGetConfig: string = path.resolve(
processRoot,
existingFileLocation == '' ? 'nuget.config' : existingFileLocation
existingFileLocation == ''
vsafonkin marked this conversation as resolved.
Show resolved Hide resolved
? getExistingNugetConfig(processRoot)
: existingFileLocation
);

const tempNuGetConfig: string = path.resolve(
Expand All @@ -25,6 +27,16 @@ export function configAuthentication(
writeFeedToFile(feedUrl, existingNuGetConfig, tempNuGetConfig);
}

function getExistingNugetConfig(processRoot: string) {
const configFileNames = fs
.readdirSync(processRoot)
.filter(filename => filename.toLowerCase() == 'nuget.config');
vsafonkin marked this conversation as resolved.
Show resolved Hide resolved
if (configFileNames.length) {
return configFileNames[0];
}
return 'nuget.config';
}

function writeFeedToFile(
feedUrl: string,
existingFileLocation: string,
Expand Down