docs.sheetjs.com/tests/engines/hermes-cli.sh
2026-03-09 00:32:12 -04:00

38 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# https://docs.sheetjs.com/docs/demos/engines/hermes#cli-test
set -e
HERMES_VERSION="0.13.0"
cd /tmp
rm -rf sheetjs-hermes-cli
mkdir -p sheetjs-hermes-cli
cd sheetjs-hermes-cli
npx -y jsvu hermes@${HERMES_VERSION}
HERMES_BIN=$(find ~/.jsvu/engines/hermes-${HERMES_VERSION} -name "hermes-${HERMES_VERSION}" -type f | head -1)
if [ -z "$HERMES_BIN" ]; then echo "Failed to find Hermes binary"; exit 1; fi
cp "$HERMES_BIN" .
curl -LO https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js
curl -LO https://docs.sheetjs.com/pres.numbers
node -e "fs.writeFileSync('payload.js', 'var payload = \"' + fs.readFileSync('pres.numbers').toString('base64') + '\";')"
cat > global.js << 'EOF'
var global = (function(){ return this; }).call(null);
var console = { log: function(x) { print(x); } };
EOF
cat > hermes.js << 'EOF'
var wb = XLSX.read(payload, {type:'base64'});
console.log(XLSX.utils.sheet_to_csv(wb.Sheets[wb.SheetNames[0]]));
EOF
cat global.js xlsx.full.min.js payload.js hermes.js > sheetjs.hermes.js
./hermes-${HERMES_VERSION} sheetjs.hermes.js