🐛 fix(projectdo): disabled npm run if to always use npm run

This commit is contained in:
Sergio Laín 2023-11-16 15:40:25 +01:00
parent d357133ae1
commit de8a417063
No known key found for this signature in database
GPG key ID: 14C9B8080681777B

View file

@ -40,7 +40,7 @@ execute() {
if [ $QUIET = false ]; then
eval "$1" $TOOL_ARGS
else
eval "$1" $TOOL_ARGS > /dev/null
eval "$1" $TOOL_ARGS >/dev/null
fi
fi
}
@ -85,17 +85,17 @@ try_nodejs() {
fi
local node_action="$ACTION"
# Only the "run" action need translation, the others match 1-to-1
if [ "$ACTION" = run ]; then
node_action=start
fi
# if [ "$ACTION" = run ]; then
# node_action=start
# fi
# We check if the package.json file contains an appropriate script. We use
# grep for this. The check is not 100% bulletproof, but it's very close. We
# could've used `npm run` to get the authorative list of the scripts but
# invoking `npm` is two orders of magnitude slower which leads to a
# noticeable delay.
if ! $IS_TOOL && ! grep -q "^[[:space:]]*\"${node_action}\":" package.json; then
return 0
fi
# if ! $IS_TOOL && ! grep -q "^[[:space:]]*\"${node_action}\":" package.json; then
# return 0
# fi
execute_command "$tool" "$node_action"
}
@ -131,7 +131,7 @@ try_stack() {
# Haskell + Cabal
try_cabal() {
cabal_file="$(find ./ -maxdepth 1 -name "*.cabal" 2> /dev/null | wc -l)"
cabal_file="$(find ./ -maxdepth 1 -name "*.cabal" 2>/dev/null | wc -l)"
if [ "$cabal_file" -gt 0 ] && [ ! -f stack.yml ]; then
execute_command cabal "$ACTION"
fi
@ -144,13 +144,16 @@ try_maven() {
case $ACTION in
build)
execute "mvn compile"
exit ;;
exit
;;
test)
execute "mvn test"
exit ;;
exit
;;
run)
echo "projectdo does not know how to run a project with Maven."
exit
;;
esac
fi
}
@ -178,7 +181,7 @@ has_make_target() {
# message. We need to consider that case as a "target not found". Note that
# the way the target is quoted in the output (`test' vs 'test') can differ
# across OSes so we only check a prefix up to the problematic quotes.
if expr "$output" : "make: Nothing to be done for" 1> /dev/null; then
if expr "$output" : "make: Nothing to be done for" 1>/dev/null; then
return 1
fi
@ -217,15 +220,18 @@ try_python() {
case $ACTION in
build)
execute "poetry build"
exit ;;
exit
;;
test)
# TODO: There are other Python test frameworks, it would be nice to
# detect and run the right one.
execute "poetry run pytest"
exit ;;
exit
;;
run)
echo "projectdo does not know how to run a project with Poetry."
exit
;;
esac
else
echo "Found a pyproject.toml file but projectdo is not sure how to run it."
@ -291,7 +297,7 @@ set_project_root() {
# git submodule then the root of the outer git repo is used. If we're not
# in a git repo the git command will not output anything and $PROJECT_ROOT
# is set to the empty string which is fine.
PROJECT_ROOT=$(git rev-parse --show-superproject-working-tree --show-toplevel 2> /dev/null | head -n 1)
PROJECT_ROOT=$(git rev-parse --show-superproject-working-tree --show-toplevel 2>/dev/null | head -n 1)
fi
}
@ -322,27 +328,41 @@ Tool arguments:
# Main execution starts here
while getopts dhnqv-: c
do
while getopts dhnqv-: c; do
case $c in
d) DRY_RUN=true ;;
h) display_help; exit 0 ;;
h)
display_help
exit 0
;;
n) DRY_RUN=true ;;
q) QUIET=true ;;
v) display_version; exit 0 ;;
v)
display_version
exit 0
;;
-) case $OPTARG in
help) display_help; exit 0 ;;
help)
display_help
exit 0
;;
dry-run) DRY_RUN=true ;;
quiet) QUIET=true ;;
version) display_version; exit 0 ;;
'' ) break ;; # "--" should terminate argument processing
* ) echo "Illegal option --$OPTARG" >&2; exit 1 ;;
version)
display_version
exit 0
;;
'') break ;; # "--" should terminate argument processing
*)
echo "Illegal option --$OPTARG" >&2
exit 1
;;
esac ;;
\?) exit 1 ;;
esac
done
shift $((OPTIND-1)) # Shift away the parsed option arguments
shift $((OPTIND - 1)) # Shift away the parsed option arguments
if [ "$1" = test ] ||
[ "$1" = run ] ||
@ -369,8 +389,7 @@ fi
set_project_root
while :
do
while :; do
# We don't want to do anything if we are in the home or root directory
if [ "$PWD" = "$HOME" ] || [ "$PWD" = / ]; then
nothing_found