diff --git a/scripts/bundle-a2ui.sh b/scripts/bundle-a2ui.sh index a1cf7ff2b..8c7d05fd0 100755 --- a/scripts/bundle-a2ui.sh +++ b/scripts/bundle-a2ui.sh @@ -30,11 +30,10 @@ collect_files() { } compute_hash() { + # Use Node.js for cross-platform hash computation (works on Windows, macOS, Linux) collect_files \ | LC_ALL=C sort -z \ - | xargs -0 shasum -a 256 \ - | shasum -a 256 \ - | awk '{print $1}' + | xargs -0 node "$ROOT_DIR/scripts/compute-file-hash.mjs" } current_hash="$(compute_hash)" diff --git a/scripts/compute-file-hash.mjs b/scripts/compute-file-hash.mjs new file mode 100755 index 000000000..3cdeff176 --- /dev/null +++ b/scripts/compute-file-hash.mjs @@ -0,0 +1,19 @@ +#!/usr/bin/env node +import { createHash } from "node:crypto"; +import { readFileSync } from "node:fs"; + +// Compute SHA-256 hash of all input files (cross-platform) +const files = process.argv.slice(2); +const hash = createHash("sha256"); + +for (const file of files) { + try { + const content = readFileSync(file); + hash.update(content); + } catch (err) { + // Skip files that don't exist or can't be read + process.stderr.write(`Warning: Could not read ${file}: ${err.message}\n`); + } +} + +console.log(hash.digest("hex"));