Skip to content

Commit

Permalink
Replaced rePatterns.<commit|sri>Hash.exec() fallbacks using shorter…
Browse files Browse the repository at this point in the history
… optional chaining ↞ [auto-sync from https://github.com/adamlui/ai-web-extensions]
  • Loading branch information
kudo-sync-bot committed Dec 16, 2024
1 parent e93eecd commit 8cda2b8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/bump/js-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@
const resourceName = (rePatterns.resourceName.exec(jsrURL) || ['resource'])[0] // dir/filename.js for logs

// Compare commit hashes
if ((rePatterns.commitHash.exec(jsrURL) || [])[1] == latestCommitHash) { // commit hash didn't change...
if (rePatterns.commitHash.exec(jsrURL)?.[1] == latestCommitHash) { // commit hash didn't change...
console.log(`${resourceName} already up-to-date!\n`) ; continue } // ...so skip resource
let updatedURL = jsrURL.replace(rePatterns.commitHash, `@${latestCommitHash}`) // othrwise update commit hash

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

Expand Down

0 comments on commit 8cda2b8

Please sign in to comment.