forked from KomodoPlatform/react-komodefi-wasm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_wasm.sh
executable file
·26 lines (24 loc) · 894 Bytes
/
update_wasm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
[ ! -d wasm_versions ] && mkdir wasm_versions
cd wasm_versions
fn=${1##*/}
[ ! -f $fn ] && wget $1
mkdir temp
unzip $fn -d temp
cd temp
mv kdflib_bg.wasm ../../public/kdflib_bg.wasm
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s|input = new URL('kdflib_bg.wasm', import.meta.url);|input = new URL('kdflib_bg.wasm', process.env.NEXT_PUBLIC_BASE_PATH);|" kdflib.js
else
sed -i "s|input = new URL('kdflib_bg.wasm', import.meta.url);|input = new URL('kdflib_bg.wasm', process.env.NEXT_PUBLIC_BASE_PATH);|" kdflib.js
fi
mv kdflib.js ../../src/js/kdflib.js
cp -r snippets/* ../../src/js/snippets/
cd ..
rm -rf temp
cd ..
basename=$(basename "$fn" .zip) # Remove .zip from filename
temp=${basename#*_}
version=${temp%-wasm} # Remove everything up to and including the first underscore
echo "NEXT_PUBLIC_WASM_VERSION=$version" > .env
echo "NEXT_PUBLIC_BASE_PATH=\"\"" >> .env