fetch-yarn-deps: handle yarn.lock deps without a resolved url

This commit is contained in:
Doron Behar 2024-06-07 18:40:16 +03:00
parent d544d8d66c
commit 2400268a38

View File

@ -12,6 +12,15 @@ const fixupYarnLock = async (lockContents, verbose) => {
const fixedData = Object.fromEntries( const fixedData = Object.fromEntries(
Object.entries(lockData.object) Object.entries(lockData.object)
.map(([dep, pkg]) => { .map(([dep, pkg]) => {
if (pkg.resolved === undefined) {
console.warn(`no resolved URL for package ${dep}`)
var maybeFile = dep.split("@", 2)[1]
if (maybeFile.startsWith("file:")) {
console.log(`Rewriting URL for local file dependency ${dep}`)
pkg.resolved = maybeFile
}
return [dep, pkg]
}
const [ url, hash ] = pkg.resolved.split("#", 2) const [ url, hash ] = pkg.resolved.split("#", 2)
if (hash || url.startsWith("https://codeload.github.com")) { if (hash || url.startsWith("https://codeload.github.com")) {