diff --git a/src/wrappers/themis/jsthemis/install_centos7_specific_deps.sh b/src/wrappers/themis/jsthemis/install_centos7_specific_deps.sh new file mode 100755 index 000000000..ccf6561be --- /dev/null +++ b/src/wrappers/themis/jsthemis/install_centos7_specific_deps.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# +# centos:7 has pretty old Node (v8) which is not supported by many packages, +# including mocha - test framework that we use. Therefore, we need to downgrade +# it for testing. The addon itself works fine, we just cannot test it without +# this patch. + + +set -e -o pipefail + +OS=$(cat /etc/*-release | grep '^NAME' | tr -d 'NAME="' || true) +VERSION=$(cat /etc/*-release | grep '^VERSION_ID' | tr -d 'VERSION_ID="' || true) + +if [[ "$OS" == "CentOS Linux" && "$VERSION" == "7" ]]; then + npm install mocha@7 --save-dev +fi diff --git a/src/wrappers/themis/jsthemis/package.json b/src/wrappers/themis/jsthemis/package.json index 2510c2bdc..4f968edc0 100644 --- a/src/wrappers/themis/jsthemis/package.json +++ b/src/wrappers/themis/jsthemis/package.json @@ -5,7 +5,8 @@ "main": "build/Release/jsthemis.node", "scripts": { "test": "mocha", - "preuninstall": "rm -rf build/*" + "preuninstall": "rm -rf build/*", + "install_centos7_specific_deps": "./install_centos7_specific_deps.sh" }, "repository": { "type": "git", diff --git a/tests/test.mk b/tests/test.mk index a3485bcc1..ca5bfe22a 100644 --- a/tests/test.mk +++ b/tests/test.mk @@ -148,7 +148,7 @@ ifdef NPM_VERSION @echo "Running jsthemis tests." @echo "In case of errors, see https://docs.cossacklabs.com/themis/languages/nodejs/" @echo "------------------------------------------------------------" - cd $(JSTHEMIS_SRC) && npm install && npm test + cd $(JSTHEMIS_SRC) && npm run install_centos7_specific_deps && npm install && npm test @echo "------------------------------------------------------------" endif