🐛 fix(projectdo): disabled npm run if to always use npm run
This commit is contained in:
parent
d357133ae1
commit
de8a417063
1 changed files with 249 additions and 230 deletions
|
@ -40,7 +40,7 @@ execute() {
|
||||||
if [ $QUIET = false ]; then
|
if [ $QUIET = false ]; then
|
||||||
eval "$1" $TOOL_ARGS
|
eval "$1" $TOOL_ARGS
|
||||||
else
|
else
|
||||||
eval "$1" $TOOL_ARGS > /dev/null
|
eval "$1" $TOOL_ARGS >/dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -85,17 +85,17 @@ try_nodejs() {
|
||||||
fi
|
fi
|
||||||
local node_action="$ACTION"
|
local node_action="$ACTION"
|
||||||
# Only the "run" action need translation, the others match 1-to-1
|
# Only the "run" action need translation, the others match 1-to-1
|
||||||
if [ "$ACTION" = run ]; then
|
# if [ "$ACTION" = run ]; then
|
||||||
node_action=start
|
# node_action=start
|
||||||
fi
|
# fi
|
||||||
# We check if the package.json file contains an appropriate script. We use
|
# 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
|
# 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
|
# 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
|
# invoking `npm` is two orders of magnitude slower which leads to a
|
||||||
# noticeable delay.
|
# noticeable delay.
|
||||||
if ! $IS_TOOL && ! grep -q "^[[:space:]]*\"${node_action}\":" package.json; then
|
# if ! $IS_TOOL && ! grep -q "^[[:space:]]*\"${node_action}\":" package.json; then
|
||||||
return 0
|
# return 0
|
||||||
fi
|
# fi
|
||||||
execute_command "$tool" "$node_action"
|
execute_command "$tool" "$node_action"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ try_stack() {
|
||||||
# Haskell + Cabal
|
# Haskell + Cabal
|
||||||
|
|
||||||
try_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
|
if [ "$cabal_file" -gt 0 ] && [ ! -f stack.yml ]; then
|
||||||
execute_command cabal "$ACTION"
|
execute_command cabal "$ACTION"
|
||||||
fi
|
fi
|
||||||
|
@ -144,13 +144,16 @@ try_maven() {
|
||||||
case $ACTION in
|
case $ACTION in
|
||||||
build)
|
build)
|
||||||
execute "mvn compile"
|
execute "mvn compile"
|
||||||
exit ;;
|
exit
|
||||||
|
;;
|
||||||
test)
|
test)
|
||||||
execute "mvn test"
|
execute "mvn test"
|
||||||
exit ;;
|
exit
|
||||||
|
;;
|
||||||
run)
|
run)
|
||||||
echo "projectdo does not know how to run a project with Maven."
|
echo "projectdo does not know how to run a project with Maven."
|
||||||
exit
|
exit
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -178,7 +181,7 @@ has_make_target() {
|
||||||
# message. We need to consider that case as a "target not found". Note that
|
# 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
|
# 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.
|
# 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
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -217,15 +220,18 @@ try_python() {
|
||||||
case $ACTION in
|
case $ACTION in
|
||||||
build)
|
build)
|
||||||
execute "poetry build"
|
execute "poetry build"
|
||||||
exit ;;
|
exit
|
||||||
|
;;
|
||||||
test)
|
test)
|
||||||
# TODO: There are other Python test frameworks, it would be nice to
|
# TODO: There are other Python test frameworks, it would be nice to
|
||||||
# detect and run the right one.
|
# detect and run the right one.
|
||||||
execute "poetry run pytest"
|
execute "poetry run pytest"
|
||||||
exit ;;
|
exit
|
||||||
|
;;
|
||||||
run)
|
run)
|
||||||
echo "projectdo does not know how to run a project with Poetry."
|
echo "projectdo does not know how to run a project with Poetry."
|
||||||
exit
|
exit
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
echo "Found a pyproject.toml file but projectdo is not sure how to run it."
|
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
|
# 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
|
# in a git repo the git command will not output anything and $PROJECT_ROOT
|
||||||
# is set to the empty string which is fine.
|
# 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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,27 +328,41 @@ Tool arguments:
|
||||||
|
|
||||||
# Main execution starts here
|
# Main execution starts here
|
||||||
|
|
||||||
while getopts dhnqv-: c
|
while getopts dhnqv-: c; do
|
||||||
do
|
|
||||||
case $c in
|
case $c in
|
||||||
d) DRY_RUN=true ;;
|
d) DRY_RUN=true ;;
|
||||||
h) display_help; exit 0 ;;
|
h)
|
||||||
|
display_help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
n) DRY_RUN=true ;;
|
n) DRY_RUN=true ;;
|
||||||
q) QUIET=true ;;
|
q) QUIET=true ;;
|
||||||
v) display_version; exit 0 ;;
|
v)
|
||||||
|
display_version
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
-) case $OPTARG in
|
-) case $OPTARG in
|
||||||
help) display_help; exit 0 ;;
|
help)
|
||||||
|
display_help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
dry-run) DRY_RUN=true ;;
|
dry-run) DRY_RUN=true ;;
|
||||||
quiet) QUIET=true ;;
|
quiet) QUIET=true ;;
|
||||||
version) display_version; exit 0 ;;
|
version)
|
||||||
'' ) break ;; # "--" should terminate argument processing
|
display_version
|
||||||
* ) echo "Illegal option --$OPTARG" >&2; exit 1 ;;
|
exit 0
|
||||||
|
;;
|
||||||
|
'') break ;; # "--" should terminate argument processing
|
||||||
|
*)
|
||||||
|
echo "Illegal option --$OPTARG" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac ;;
|
esac ;;
|
||||||
\?) exit 1 ;;
|
\?) exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
shift $((OPTIND-1)) # Shift away the parsed option arguments
|
shift $((OPTIND - 1)) # Shift away the parsed option arguments
|
||||||
|
|
||||||
if [ "$1" = test ] ||
|
if [ "$1" = test ] ||
|
||||||
[ "$1" = run ] ||
|
[ "$1" = run ] ||
|
||||||
|
@ -369,8 +389,7 @@ fi
|
||||||
|
|
||||||
set_project_root
|
set_project_root
|
||||||
|
|
||||||
while :
|
while :; do
|
||||||
do
|
|
||||||
# We don't want to do anything if we are in the home or root directory
|
# We don't want to do anything if we are in the home or root directory
|
||||||
if [ "$PWD" = "$HOME" ] || [ "$PWD" = / ]; then
|
if [ "$PWD" = "$HOME" ] || [ "$PWD" = / ]; then
|
||||||
nothing_found
|
nothing_found
|
||||||
|
|
Loading…
Add table
Reference in a new issue