2020-02-19 08:06:35 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-04-30 19:52:54 +08:00
|
|
|
pushd() {
|
|
|
|
builtin pushd "$@" > /dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
popd() {
|
|
|
|
builtin popd > /dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
pkg_json_version() {
|
|
|
|
jq -r .version package.json
|
|
|
|
}
|
|
|
|
|
|
|
|
os() {
|
|
|
|
local os
|
|
|
|
os=$(uname | tr '[:upper:]' '[:lower:]')
|
|
|
|
if [[ $os == "linux" ]]; then
|
|
|
|
# Alpine's ldd doesn't have a version flag but if you use an invalid flag
|
|
|
|
# (like --version) it outputs the version to stderr and exits with 1.
|
|
|
|
local ldd_output
|
|
|
|
ldd_output=$(ldd --version 2>&1 || true)
|
|
|
|
if echo "$ldd_output" | grep -iq musl; then
|
|
|
|
os="alpine"
|
|
|
|
fi
|
2020-02-19 08:06:35 +08:00
|
|
|
fi
|
2020-04-30 19:52:54 +08:00
|
|
|
echo "$os"
|
|
|
|
}
|
|
|
|
|
|
|
|
arch() {
|
|
|
|
case "$(uname -m)" in
|
|
|
|
aarch64)
|
|
|
|
echo arm64
|
|
|
|
;;
|
|
|
|
x86_64)
|
|
|
|
echo amd64
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "unknown architecture $(uname -a)"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2020-02-19 08:06:35 +08:00
|
|
|
}
|