15 lines
501 B
Plaintext
15 lines
501 B
Plaintext
|
#!/bin/bash
|
||
|
# Use as alternative to npm to run in local node.js environment
|
||
|
# REQUIRES python3, else falls back to system-wide npm
|
||
|
|
||
|
set -e
|
||
|
|
||
|
which python3 > /dev/null 2>&1 || ( npm "$@" && exit 0 )
|
||
|
|
||
|
dir=$(dirname $0)
|
||
|
|
||
|
test -x "${dir}/.env/bin/nodeenv" || ( virtualenv -p python3 "${dir}/.env" && "${dir}/.env/bin/pip" install --upgrade nodeenv )
|
||
|
test -f "${dir}/.env/node/bin/activate" || "${dir}/.env/bin/nodeenv" --node=latest --force "${dir}/.env/node"
|
||
|
PATH="${dir}/.env/node/bin:${PATH}" npm "$@"
|
||
|
|