fetch-yarn-deps: warn on undefined expected hash

instead of rejecting, given that the expected hash may not be known/provided.
This commit is contained in:
Dan Buch 2023-09-14 10:53:05 +00:00
parent 3ffce56f46
commit 14f76a96e8
No known key found for this signature in database
GPG Key ID: A12F782281063434

View File

@ -37,7 +37,9 @@ const downloadFileHttps = (fileName, url, expectedHash, hashType = 'sha1') => {
res.on('end', () => {
file.close()
const h = hash.read()
if (h != expectedHash) return reject(new Error(`hash mismatch, expected ${expectedHash}, got ${h}`))
if (expectedHash === undefined){
console.log(`Warning: lockfile url ${url} doesn't end in "#<hash>" to validate against. Downloaded file had hash ${h}.`);
} else if (h != expectedHash) return reject(new Error(`hash mismatch, expected ${expectedHash}, got ${h}`))
resolve()
})
res.on('error', e => reject(e))