setup cargo run to use containerized build tools that are not rust tools
This commit is contained in:
29
bin/npm
Executable file
29
bin/npm
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
CONTAINER_IMAGE="localhost/esp-plant-dev-tools:latest"
|
||||
CONTAINER_TOOLS_BASEDIR="$(dirname "$(readlink -f "$0")")"
|
||||
PLANTCTL_PROJECT_DIR="$(readlink -f "$CONTAINER_TOOLS_BASEDIR/..")"
|
||||
|
||||
function _fatal {
|
||||
echo -e "\e[31mERROR\e[0m $(</dev/stdin)$*" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
declare -a PODMAN_ARGS=(
|
||||
"--rm" "-i" "--log-driver=none"
|
||||
"-v" "$PLANTCTL_PROJECT_DIR:$PLANTCTL_PROJECT_DIR:rw"
|
||||
"-v" "$PWD:$PWD:rw"
|
||||
"-w" "$PWD"
|
||||
)
|
||||
|
||||
[[ -t 1 ]] && PODMAN_ARGS+=("-t")
|
||||
|
||||
if ! podman image exists "$CONTAINER_IMAGE"; then
|
||||
#attempt to build container
|
||||
"$CONTAINER_TOOLS_BASEDIR/build-esp-plant-dev-tools.sh" 1>&2 ||
|
||||
_fatal "faild to build local image, cannot continue! … please ensure you have an internet connection"
|
||||
fi
|
||||
|
||||
podman run "${PODMAN_ARGS[@]}" --entrypoint npm "$CONTAINER_IMAGE" "$@"
|
Reference in New Issue
Block a user