From 0d8e3174905a78759e373f643cfb017091d3aff0 Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Tue, 22 Jun 2021 15:32:20 +0200 Subject: [PATCH] build.sh: Detect local installs of rollup and improve error messages --- app/build.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/app/build.sh b/app/build.sh index ab5f515..7a9fc28 100755 --- a/app/build.sh +++ b/app/build.sh @@ -1,5 +1,27 @@ #! /bin/sh cd $(dirname $0) +if ! which wasm-pack > /dev/null 2>&1 +then + >&2 echo '`wasm-pack` not found. Try running `cargo install wasm-pack`' + exit 1 +fi + wasm-pack build --target web -rollup ./main.js --format iife --file ./pkg/bundle.js + +ROLLUP_BIN=$(which rollup 2>/dev/null) +if [ -f ../node_modules/rollup/dist/bin/rollup ] +then + ROLLUP_BIN=../node_modules/rollup/dist/bin/rollup +elif [ -f node_modules/rollup/dist/bin/rollup ] +then + ROLLUP_BIN=node_modules/rollup/dist/bin/rollup +fi + +if [ -z "$ROLLUP_BIN" ] +then + >&2 echo '`rollup` not found. Try running `npm install rollup`' + exit 1 +fi + +$ROLLUP_BIN ./main.js --format iife --file ./pkg/bundle.js