aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/build/generate-sri.js
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twbs/bootstrap/build/generate-sri.js')
-rw-r--r--vendor/twbs/bootstrap/build/generate-sri.js22
1 files changed, 14 insertions, 8 deletions
diff --git a/vendor/twbs/bootstrap/build/generate-sri.js b/vendor/twbs/bootstrap/build/generate-sri.js
index 10936e8a1..a93f3e538 100644
--- a/vendor/twbs/bootstrap/build/generate-sri.js
+++ b/vendor/twbs/bootstrap/build/generate-sri.js
@@ -5,18 +5,20 @@
* Remember to use the same vendor files as the CDN ones,
* otherwise the hashes won't match!
*
- * Copyright 2017-2018 The Bootstrap Authors
- * Copyright 2017-2018 Twitter, Inc.
+ * Copyright 2017-2019 The Bootstrap Authors
+ * Copyright 2017-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
'use strict'
+const crypto = require('crypto')
const fs = require('fs')
const path = require('path')
-const sriToolbox = require('sri-toolbox')
const sh = require('shelljs')
+const pkg = require('../package.json')
+
sh.config.fatal = true
const configFile = path.join(__dirname, '../_config.yml')
@@ -34,11 +36,15 @@ const files = [
configPropertyName: 'js_hash'
},
{
- file: 'site/docs/4.1/assets/js/vendor/jquery-slim.min.js',
+ file: 'dist/js/bootstrap.bundle.min.js',
+ configPropertyName: 'js_bundle_hash'
+ },
+ {
+ file: `site/docs/${pkg.version_short}/assets/js/vendor/jquery-slim.min.js`,
configPropertyName: 'jquery_hash'
},
{
- file: 'site/docs/4.1/assets/js/vendor/popper.min.js',
+ file: 'node_modules/popper.js/dist/umd/popper.min.js',
configPropertyName: 'popper_hash'
}
]
@@ -49,9 +55,9 @@ files.forEach((file) => {
throw err
}
- const integrity = sriToolbox.generate({
- algorithms: ['sha384']
- }, data)
+ const algo = 'sha384'
+ const hash = crypto.createHash(algo).update(data, 'utf8').digest('base64')
+ const integrity = `${algo}-${hash}`
console.log(`${file.configPropertyName}: ${integrity}`)