docs.sheetjs.com/tests/cli/pkg.sh
2026-01-22 01:59:11 -05:00

34 lines
800 B
Bash
Executable File

#!/bin/bash
# https://docs.sheetjs.com/docs/demos/cli/pkg
cd /tmp
rm -rf sheetjs-pkg
mkdir sheetjs-pkg
cd sheetjs-pkg
curl -o pres.numbers https://docs.sheetjs.com/pres.numbers
curl -o xlsx-cli.js https://docs.sheetjs.com/cli/xlsx-cli.js
npm i --save https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz exit-on-epipe commander@2
OS="$(uname -s)"
ARCH="$(uname -m)"
case "$OS" in
Darwin) OS="macos" ;;
Linux) OS="linux" ;;
*) echo "unsupported OS: $OS"; exit 1 ;;
esac
case "$ARCH" in
x86_64) ARCH="x64" ;;
arm64|aarch64) ARCH="arm64" ;;
*) echo "unsupported arch: $ARCH"; exit 1 ;;
esac
# Build for the current platform
npx -y pkg -t "node18-win-${ARCH},node18-linux-${ARCH},node18-macos-${ARCH}" xlsx-cli.js
# Run the appropriate binary based on OS
./xlsx-cli-${OS} pres.numbers