summaryrefslogtreecommitdiffstats
path: root/build/generate-sri.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--build/generate-sri.mjs (renamed from build/generate-sri.js)17
1 files changed, 9 insertions, 8 deletions
diff --git a/build/generate-sri.js b/build/generate-sri.mjs
index 2e22924..e2b1554 100644
--- a/build/generate-sri.js
+++ b/build/generate-sri.mjs
@@ -9,12 +9,13 @@
* 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}`)