mirror of
https://github.com/actions/setup-dotnet.git
synced 2024-11-22 19:41:08 +07:00
build
This commit is contained in:
parent
e5034212c9
commit
792e988dae
44
dist/index.js
vendored
44
dist/index.js
vendored
@ -55,6 +55,7 @@ function getExistingNugetConfig(processRoot) {
|
|||||||
return defaultConfigName;
|
return defaultConfigName;
|
||||||
}
|
}
|
||||||
function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) {
|
function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) {
|
||||||
|
var _a, _b;
|
||||||
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;
|
||||||
let sourceKeys = [];
|
let sourceKeys = [];
|
||||||
@ -69,35 +70,30 @@ function writeFeedToFile(feedUrl, existingFileLocation, tempFileLocation) {
|
|||||||
if (fs.existsSync(existingFileLocation)) {
|
if (fs.existsSync(existingFileLocation)) {
|
||||||
// get key from existing NuGet.config so NuGet/dotnet can match credentials
|
// get key from existing NuGet.config so NuGet/dotnet can match credentials
|
||||||
const curContents = fs.readFileSync(existingFileLocation, 'utf8');
|
const curContents = fs.readFileSync(existingFileLocation, 'utf8');
|
||||||
var json = xmlParser.parse(curContents, { ignoreAttributes: false });
|
const json = xmlParser.parse(curContents, { ignoreAttributes: false });
|
||||||
if (typeof json.configuration == 'undefined') {
|
if (typeof json.configuration === 'undefined') {
|
||||||
throw new Error(`The provided NuGet.config seems invalid.`);
|
throw new Error(`The provided NuGet.config seems invalid.`);
|
||||||
}
|
}
|
||||||
if (typeof json.configuration.packageSources != 'undefined') {
|
if ((_b = (_a = json.configuration) === null || _a === void 0 ? void 0 : _a.packageSources) === null || _b === void 0 ? void 0 : _b.add) {
|
||||||
if (typeof json.configuration.packageSources.add != 'undefined') {
|
const packageSources = json.configuration.packageSources.add;
|
||||||
// file has at least one <add>
|
if (Array.isArray(packageSources)) {
|
||||||
if (typeof json.configuration.packageSources.add[0] == 'undefined') {
|
packageSources.forEach(source => {
|
||||||
// file has only one <add>
|
const value = source['@_value'];
|
||||||
if (json.configuration.packageSources.add['@_value']
|
core.debug(`source '${value}'`);
|
||||||
.toLowerCase()
|
if (value.toLowerCase().includes(feedUrl.toLowerCase())) {
|
||||||
.includes(feedUrl.toLowerCase())) {
|
const key = source['@_key'];
|
||||||
let key = json.configuration.packageSources.add['@_key'];
|
|
||||||
sourceKeys.push(key);
|
sourceKeys.push(key);
|
||||||
core.debug(`Found a URL with key ${key}`);
|
core.debug(`Found a URL with key ${key}`);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
else {
|
}
|
||||||
// file has 2+ <add>
|
else {
|
||||||
for (let i = 0; i < json.configuration.packageSources.add.length; i++) {
|
if (packageSources['@_value']
|
||||||
const source = json.configuration.packageSources.add[i];
|
.toLowerCase()
|
||||||
const value = source['@_value'];
|
.includes(feedUrl.toLowerCase())) {
|
||||||
core.debug(`source '${value}'`);
|
const key = packageSources['@_key'];
|
||||||
if (value.toLowerCase().includes(feedUrl.toLowerCase())) {
|
sourceKeys.push(key);
|
||||||
let key = source['@_key'];
|
core.debug(`Found a URL with key ${key}`);
|
||||||
sourceKeys.push(key);
|
|
||||||
core.debug(`Found a URL with key ${key}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user