Skip to content

Commit

Permalink
generate-sri.js: use destructuring (#38413)
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR authored Apr 9, 2023
1 parent d0cc42c commit 3d84e60
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions build/generate-sri.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const files = [
}
]

for (const file of files) {
fs.readFile(file.file, 'utf8', (error, data) => {
for (const { file, configPropertyName } of files) {
fs.readFile(file, 'utf8', (error, data) => {
if (error) {
throw error
}
Expand All @@ -56,8 +56,8 @@ for (const file of files) {
const hash = crypto.createHash(algo).update(data, 'utf8').digest('base64')
const integrity = `${algo}-${hash}`

console.log(`${file.configPropertyName}: ${integrity}`)
console.log(`${configPropertyName}: ${integrity}`)

sh.sed('-i', new RegExp(`^(\\s+${file.configPropertyName}:\\s+["'])\\S*(["'])`), `$1${integrity}$2`, configFile)
sh.sed('-i', new RegExp(`^(\\s+${configPropertyName}:\\s+["'])\\S*(["'])`), `$1${integrity}$2`, configFile)
})
}

0 comments on commit 3d84e60

Please sign in to comment.