Commit 6b2fcff3 authored by David Sveningsson's avatar David Sveningsson
Browse files

prefer-npm: print to stderr and only if stderr is a tty

parent ffb5d333
......@@ -31,12 +31,18 @@ local="${root}/node_modules/.bin/${cmd}"
global=$(PATH=${PATH/$(dirname $0)//} which "${cmd}" 2> /dev/null)
if [[ -n "${root}" && -e "${root}/node_modules/.bin/${cmd}" ]]; then
echo "Using $(realpath --relative-to=. ${local})"
if [ -t 2 ] ; then
echo "Using $(realpath --relative-to=. ${local})" > /dev/stderr
fi
exec "${local}" "$@"
elif [[ -n "${global}" ]]; then
echo "Using ${global}"
if [ -t 2 ] ; then
echo "Using ${global}" > /dev/stderr
fi
exec "${global}" "$@"
else
echo "${cmd}: command not found"
if [ -t 2 ] ; then
echo "${cmd}: command not found" > /dev/stderr
fi
exit 1
fi
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment