diff options
Diffstat (limited to '')
-rw-r--r-- | build/generate-sri.js | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/build/generate-sri.js b/build/generate-sri.js index ef1b39f..2e22924 100644 --- a/build/generate-sri.js +++ b/build/generate-sri.js @@ -5,8 +5,7 @@ * Remember to use the same vendor files as the CDN ones, * otherwise the hashes won't match! * - * Copyright 2017-2022 The Bootstrap Authors - * Copyright 2017-2022 Twitter, Inc. + * Copyright 2017-2023 The Bootstrap Authors * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ @@ -19,11 +18,11 @@ const sh = require('shelljs') sh.config.fatal = true -const configFile = path.join(__dirname, '../config.yml') +const configFile = path.join(__dirname, '../hugo.yml') // Array of objects which holds the files to generate SRI hashes for. // `file` is the path from the root folder -// `configPropertyName` is the config.yml variable's name of the file +// `configPropertyName` is the hugo.yml variable's name of the file const files = [ { file: 'dist/css/bootstrap.min.css', @@ -47,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 } @@ -57,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) }) } |