From d206dee048854591956c50775794adb0d859cafc Mon Sep 17 00:00:00 2001 From: Caio Ramos Casimiro Date: Tue, 30 Jan 2024 18:40:47 +0000 Subject: [PATCH] chore(util) ensure SDK examples exist before installing them This prevents `./util/test.sh` from failing if `./util/sdk.sh` is called to install example filters when the respective SDK hasn't been downloaded, i.e., `tinygo` or `npm` not available. --- util/sdks/assemblyscript.sh | 18 ++++++++++-------- util/sdks/go.sh | 22 ++++++++++++---------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/util/sdks/assemblyscript.sh b/util/sdks/assemblyscript.sh index 31881303a..96e932557 100755 --- a/util/sdks/assemblyscript.sh +++ b/util/sdks/assemblyscript.sh @@ -93,14 +93,16 @@ build_assemblyscript_sdk() { } install_assemblyscript_sdk_examples() { - for example in $DIR_PROXY_WASM_ASSEMBLYSCRIPT_SDK/examples/*; do - name=$(basename $example) - name=$(echo $name | sed 's/-/_/g') - - pushd $example - cp -av build/debug.wasm $DIR_TESTS_LIB_WASM/assemblyscript_$name.wasm - popd - done + if [[ -d "$DIR_PROXY_WASM_ASSEMBLYSCRIPT_SDK/examples" ]]; then + for example in $DIR_PROXY_WASM_ASSEMBLYSCRIPT_SDK/examples/*; do + name=$(basename $example) + name=$(echo $name | sed 's/-/_/g') + + pushd $example + cp -av build/debug.wasm $DIR_TESTS_LIB_WASM/assemblyscript_$name.wasm + popd + done + fi } ############################################################################### diff --git a/util/sdks/go.sh b/util/sdks/go.sh index 8482f25be..9e40031e8 100755 --- a/util/sdks/go.sh +++ b/util/sdks/go.sh @@ -110,16 +110,18 @@ EOF } install_go_sdk_examples() { - pushd $DIR_PATCHED_PROXY_WASM_GO_SDK - cd examples - - find . -name "*.wasm" | while read f; do - # flatten module names, for example: - # "./shared_queue/sender/main.wasm" to "go_shared_queue_sender.wasm" - name=$(echo "$f" | sed 's,./\(.*\)/main.wasm,go_\1.wasm,;s,/,_,g') - cp -av "$f" "$DIR_TESTS_LIB_WASM/$name" - done - popd + if [[ -d "$DIR_PATCHED_PROXY_WASM_GO_SDK" ]]; then + pushd $DIR_PATCHED_PROXY_WASM_GO_SDK + cd examples + + find . -name "*.wasm" | while read f; do + # flatten module names, for example: + # "./shared_queue/sender/main.wasm" to "go_shared_queue_sender.wasm" + name=$(echo "$f" | sed 's,./\(.*\)/main.wasm,go_\1.wasm,;s,/,_,g') + cp -av "$f" "$DIR_TESTS_LIB_WASM/$name" + done + popd + fi } ###############################################################################