summaryrefslogtreecommitdiffstats
path: root/build/generate-sri.mjs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--build/generate-sri.mjs (renamed from build/generate-sri.js)19
1 files changed, 10 insertions, 9 deletions
diff --git a/build/generate-sri.js b/build/generate-sri.mjs
index 2e22924..384e8f4 100644
--- a/build/generate-sri.js
+++ b/build/generate-sri.mjs
@@ -5,16 +5,17 @@
* Remember to use the same vendor files as the CDN ones,
* otherwise the hashes won't match!
*
- * Copyright 2017-2023 The Bootstrap Authors
+ * Copyright 2017-2024 The Bootstrap Authors
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
-'use strict'
+import crypto from 'node:crypto'
+import fs from 'node:fs'
+import path from 'node:path'
+import { fileURLToPath } from 'node:url'
+import sh from 'shelljs'
-const crypto = require('node:crypto')
-const fs = require('node:fs')
-const path = require('node:path')
-const sh = require('shelljs')
+const __dirname = path.dirname(fileURLToPath(import.meta.url))
sh.config.fatal = true
@@ -52,9 +53,9 @@ for (const { file, configPropertyName } of files) {
throw error
}
- const algo = 'sha384'
- const hash = crypto.createHash(algo).update(data, 'utf8').digest('base64')
- const integrity = `${algo}-${hash}`
+ const algorithm = 'sha384'
+ const hash = crypto.createHash(algorithm).update(data, 'utf8').digest('base64')
+ const integrity = `${algorithm}-${hash}`
console.log(`${configPropertyName}: ${integrity}`)