Skip to content

Commit

Permalink
Moved SRI hash log into getSRIhash() to align w/ bumpUserJSver()
Browse files Browse the repository at this point in the history
  • Loading branch information
kudo-sync-bot committed Dec 9, 2024
1 parent b0e9b4c commit 897683b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions utils/bump/jsResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@
}

async function getSRIhash(url, algorithm = 'sha256') {
return ssri.fromData(
const sriHash = ssri.fromData(
Buffer.from(await (await fetchData(url)).arrayBuffer()), { algorithms: [algorithm] }).toString()
console.log(`${sriHash}\n`)
}

function bumpUserJSver(userJSfilePath) {
Expand Down Expand Up @@ -95,9 +96,8 @@

// Generate/compare SRI hash
console.log(`Generating SHA-256 hash for ${resourceName}...`)
const newSRIhash = await getSRIhash(updatedURL)
console.log(`${newSRIhash}\n`)
const oldSRIhash = (/[^#]+$/.exec(jsrURL) || [])[0]
const newSRIhash = await getSRIhash(updatedURL),
oldSRIhash = (/[^#]+$/.exec(jsrURL) || [])[0]
if (oldSRIhash == newSRIhash) { // SRI hash didn't change
console.log(`${resourceName} already up-to-date!\n`) ; continue } // ...so skip resource
updatedURL = updatedURL.replace(/#sha.+/, newSRIhash) // otherwise update SRI hash
Expand Down

0 comments on commit 897683b

Please sign in to comment.