Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: better ./risedev l in server #18845

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,40 @@ alias = "logs"

[tasks.logs]
category = "RiseDev - Start/Stop"
description = "Open logs with VSCode or dump in console"
description = "Open logs with Editor like VSCode and vim or dump in console"
script = '''
#!/usr/bin/env bash

code "${PREFIX_LOG}" 2> /dev/null
if [[ $? -eq 0 ]]; then
exit 0
if [[ -n "$EDITOR" ]]; then
if which "$EDITOR" &> /dev/null; then
$EDITOR "${PREFIX_LOG}" 2> /dev/null
if [[ $? -eq 0 ]]; then
exit 0
fi
fi
fi

# first try to use VSCode as the editor
if command -v code &> /dev/null; then
code "${PREFIX_LOG}" 2> /dev/null
if [[ $? -eq 0 ]]; then
exit 0
fi
fi
# Second try to use vim as the editor
if command -v vim &> /dev/null; then
vim "${PREFIX_LOG}" 2> /dev/null
if [[ $? -eq 0 ]]; then
exit 0
fi
fi
# Then try to use vi as the editor
if command -v vi &> /dev/null; then
vi "${PREFIX_LOG}" 2> /dev/null
if [[ $? -eq 0 ]]; then
exit 0
fi
fi
# If no editor is available or all attempts fail, dump log files
for out_file in ${PREFIX_LOG}/*.log
do
echo "~~~ Dump log file $out_file"
Expand Down
Loading