summaryrefslogtreecommitdiffstats
path: root/build/generate-sri.mjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-24 09:22:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-24 09:22:02 +0000
commit8b9e5144f7af3bb0578d80ed619dd0743d0d5f0f (patch)
treec651acc917541c3ad4fc91eb30df52c2f07095fd /build/generate-sri.mjs
parentAdding upstream version 5.3.1+dfsg. (diff)
downloadbootstrap-html-upstream.tar.xz
bootstrap-html-upstream.zip
Adding upstream version 5.3.3+dfsg.upstream/5.3.3+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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}`)