Use like this:
node --inspect-brk $(pnpm-where _mocha) path/to/your.test.js
#!/bin/bash | |
bin_name=$1 | |
bin_path="node_modules/.bin/$bin_name" | |
bin_dir=$(dirname $bin_path) | |
if [ ! -f "$bin_path" ]; then | |
echo "$bin_path does not exists" | |
exit 1 | |
fi | |
rel=$(cat $bin_path | grep -E "basedir\/(\..+$bin_name)" | grep -oE "\..+$bin_name" | head -1) | |
function abspath { | |
if [[ -d "$1" ]] | |
then | |
pushd "$1" >/dev/null | |
pwd | |
popd >/dev/null | |
elif [[ -e "$1" ]] | |
then | |
pushd "$(dirname "$1")" >/dev/null | |
echo "$(pwd)/$(basename "$1")" | |
popd >/dev/null | |
else | |
echo "$1" does not exist! >&2 | |
return 127 | |
fi | |
} | |
js_path="$bin_dir/$rel" | |
out_path=$(abspath $js_path) | |
if [ ! -f "$out_path" ]; then | |
echo "Unable to resolve $bin_name" | |
echo "$out_path does not exists" | |
exit 1 | |
fi | |
echo $out_path |