diff --git a/GNUmakefile b/GNUmakefile index fcae9a205..35f9c0d5a 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -280,15 +280,15 @@ wasi-cm: rsync -rv --delete --exclude go.mod --exclude '*_test.go' --exclude '*_json.go' --exclude '*.md' --exclude LICENSE $(shell go list -modfile ./internal/wasm-tools/go.mod -m -f {{.Dir}} $(WASM_TOOLS_MODULE)/cm)/ ./src/internal/cm # Check for Node.js used during WASM tests. -NODEJS_VERSION := $(word 1,$(subst ., ,$(shell node -v | cut -c 2-))) MIN_NODEJS_VERSION=18 .PHONY: check-nodejs-version check-nodejs-version: -ifeq (, $(shell which node)) - @echo "Install NodeJS version 18+ to run tests."; exit 1; -endif - @if [ $(NODEJS_VERSION) -lt $(MIN_NODEJS_VERSION) ]; then echo "Install NodeJS version 18+ to run tests."; exit 1; fi + @# Check whether NodeJS is available. + @if ! command -v node 2>&1 >/dev/null; then echo "Install NodeJS version ${MIN_NODEJS_VERSION}+ to run tests."; exit 1; fi + + @# Check whether the version is high enough. + @if [ "`node -v | sed 's/v\([0-9]\+\).*/\\1/g'`" -lt $(MIN_NODEJS_VERSION) ]; then echo "Install NodeJS version $(MIN_NODEJS_VERSION)+ to run tests."; exit 1; fi tinygo: ## Build the TinyGo compiler @if [ ! -f "$(LLVM_BUILDDIR)/bin/llvm-config" ]; then echo "Fetch and build LLVM first by running:"; echo " $(MAKE) llvm-source"; echo " $(MAKE) $(LLVM_BUILDDIR)"; exit 1; fi