Skip to content

Commit af75965

Browse files
committed
chore: make install-plugins POSIX
Instead of relying on `bash` (which may not be installed, such as in alpine images), use POSIX bash. Signed-off-by: JP-Ellis <josh@jpellis.me>
1 parent fc04239 commit af75965

File tree

3 files changed

+60
-60
lines changed

3 files changed

+60
-60
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"release": "commit-and-tag-version",
1818
"test": "mocha",
1919
"coverage": "nyc npm run test",
20-
"pretest": "bash scripts/install-plugins.sh",
20+
"pretest": "./scripts/install-plugins",
2121
"docker:alpine:build": "docker build --build-arg NODE_VERSION=${NODE_VERSION:-current} -f Dockerfile.alpine -t pact-js:alpine .",
2222
"docker:debian:build": "docker build --build-arg NODE_VERSION=${NODE_VERSION:-current} -f Dockerfile.debian -t pact-js:debian .",
2323
"docker:alpine:run": "docker run -e LOG_LEVEL=${LOG_LEVEL:-info} -e GIT_REF=${GIT_REF:-test} -e GITHUB_ACTIONS=${GITHUB_ACTIONS:-false} -e SKIP_EXAMPLES=${SKIP_EXAMPLES:-''} -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN -w /home -v $(pwd):/home --rm pact-js:alpine",

scripts/install-plugins

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/sh
2+
#
3+
# Usage:
4+
# $ curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-plugins/master/install-cli.sh | bash
5+
# or
6+
# $ wget -q https://raw.githubusercontent.com/pact-foundation/pact-plugins/master/install-cli.sh -O- | bash
7+
8+
set -o errexit # Exit on error
9+
set -o nounset # Treat unset variables as an error
10+
11+
detect_osarch() {
12+
case $(uname -sm) in
13+
'Linux x86_64')
14+
os='linux'
15+
arch='x86_64'
16+
;;
17+
'Linux aarch64')
18+
os='linux'
19+
arch='aarch64'
20+
;;
21+
'Darwin x86' | 'Darwin x86_64')
22+
os='osx'
23+
arch='x86_64'
24+
;;
25+
'Darwin arm64')
26+
os='osx'
27+
arch='aarch64'
28+
;;
29+
CYGWIN* | MINGW32* | MSYS* | MINGW*)
30+
os="windows"
31+
arch='x86_64'
32+
ext='.exe'
33+
;;
34+
*)
35+
echo "Sorry, you'll need to install the plugin CLI manually."
36+
exit 1
37+
;;
38+
esac
39+
}
40+
41+
VERSION="0.1.2"
42+
detect_osarch
43+
44+
if [ ! -f ~/.pact/bin/pact-plugin-cli ]; then
45+
echo "--- 🐿 Installing plugins CLI version '${VERSION}' (from tag ${TAG})"
46+
mkdir -p ~/.pact/bin
47+
DOWNLOAD_LOCATION=https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v${VERSION}/pact-plugin-cli-${os}-${arch}${ext}.gz
48+
echo " Downloading from: ${DOWNLOAD_LOCATION}"
49+
curl -L -o ~/.pact/bin/pact-plugin-cli-${os}-${arch}.gz "${DOWNLOAD_LOCATION}"
50+
echo " Downloaded $(file ~/.pact/bin/pact-plugin-cli-${os}-${arch}.gz)"
51+
gunzip -f ~/.pact/bin/pact-plugin-cli-${os}-${arch}.gz
52+
mv ~/.pact/bin/pact-plugin-cli-${os}-${arch} ~/.pact/bin/pact-plugin-cli
53+
chmod +x ~/.pact/bin/pact-plugin-cli
54+
fi
55+
56+
if [ ! -d ~/.pact/plugins/matt-0.1.1 ]; then
57+
echo "--- 🐿 Installing MATT plugin"
58+
~/.pact/bin/pact-plugin-cli install https://github.com/mefellows/pact-matt-plugin/releases/tag/v0.1.1
59+
fi

scripts/install-plugins.sh

-59
This file was deleted.

0 commit comments

Comments
 (0)