Skip to content

Commit f5c3071

Browse files
authored
feat(script): check-deps will prompt user to install dependencies (#165)
1 parent 42c827e commit f5c3071

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

scripts/check-deps.sh

+19-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ set -e
1212
main() {
1313
script_path="$argc_script_path"
1414
if [[ ! -f "$script_path" ]]; then
15-
_exit "✗ not found $script_path"
15+
echo "✗ not found $script_path"
16+
exit 0
1617
fi
1718
ext="${script_path##*.}"
1819
if [[ "$script_path" == tools/* ]]; then
@@ -39,30 +40,39 @@ check_sh_dependencies() {
3940
fi
4041
done
4142
if [[ -n "${missing_deps}" ]]; then
42-
_exit "✗ missing tools: ${missing_deps[*]}"
43+
echo "✗ missing tools: ${missing_deps[*]}"
4344
fi
4445
}
4546

4647
check_agent_js_dependencies() {
4748
agent_dir="$(dirname "$script_path")"
4849
if [[ -f "$agent_dir/package.json" ]]; then
4950
npm ls --prefix="$agent_dir" --depth=0 --silent >/dev/null 2>&1 || \
50-
_exit "✗ missing node modules, FIX: cd $agent_dir && npm install"
51+
{
52+
cmd="cd $agent_dir && npm install"
53+
echo "✗ missing node modules"
54+
read -p "? run \`$cmd\` to fix [Y/n] " choice
55+
if [[ "$choice" == "Y" || "$choice" == "y" || -z "$choice" ]]; then
56+
(eval "$cmd")
57+
fi
58+
}
5159
fi
5260
}
5361

5462
check_agent_py_dependencies() {
5563
agent_dir="$(dirname "$script_path")"
5664
if [[ -f "$agent_dir/requirements.txt" ]]; then
5765
python <(cat "$agent_dir/requirements.txt" | sed -E -n 's/^([A-Za-z_]+).*/import \1/p') >/dev/null 2>&1 || \
58-
_exit "✗ missing python modules, FIX: cd $agent_dir && pip install -r requirements.txt"
66+
{
67+
cmd="cd $agent_dir && pip install -r requirements.txt"
68+
echo "✗ missing python modules"
69+
read -p "? run \`$cmd\` to fix [Y/n] " choice
70+
if [[ "$choice" == "Y" || "$choice" == "y" || -z "$choice" ]]; then
71+
(eval "$cmd")
72+
fi
73+
}
5974
fi
6075
}
6176

62-
_exit() {
63-
echo "$*" >&2
64-
exit 0
65-
}
66-
6777
# See more details at https://github.com/sigoden/argc
6878
eval "$(argc --argc-eval "$0" "$@")"

0 commit comments

Comments
 (0)