Append / to end of registries url

Avoids a bug in 2.10.4. Also, add some better handling for invalid
registries blocks.
This commit is contained in:
Andrew Eisenberg 2022-09-07 20:32:47 -07:00
parent 59744464eb
commit 6085805a3a
7 changed files with 119 additions and 30 deletions

7
lib/config-utils.js generated
View file

@ -1049,9 +1049,14 @@ async function downloadPacks(codeQL, languages, packs, registries, apiDetails, t
}
exports.downloadPacks = downloadPacks;
function createRegistriesBlock(registries) {
if (!Array.isArray(registries) ||
registries.some((r) => !r.url || !r.packages)) {
throw new Error("Invalid 'registries' input. Must be an array of objects with 'url' and 'packages' properties.");
}
// be sure to remove the `token` field from the registry before writing it to disk.
const safeRegistries = registries.map((registry) => ({
url: registry.url,
// ensure the url ends with a slash to avoid a bug in the CLI 2.10.4
url: !(registry === null || registry === void 0 ? void 0 : registry.url.endsWith("/")) ? `${registry.url}/` : registry.url,
packages: registry.packages,
}));
const qlconfig = {