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

Colors in startup command shown when printing command #261

Closed
srnyx opened this issue Aug 25, 2024 · 0 comments
Closed

Colors in startup command shown when printing command #261

srnyx opened this issue Aug 25, 2024 · 0 comments

Comments

@srnyx
Copy link

srnyx commented Aug 25, 2024

image

Only "No build tool detected (make sure your wrapper is set-up correctly)" should be red here, the big block of red text above it shouldn't be

Occurs due to this line: https://github.com/pelican-eggs/yolks/blob/master/java/entrypoint.sh#L47

Potential fix is by printing $PARSED using echo (assuming excluding the \n at the end of printf will have the echo be on the same line):

printf "\033[1m\033[33mcontainer@pelican~ \033[0m"
echo "$PARSED"

Simple startup command to demonstrate issue:

echo -e "\033[0;31mred text!";
Full startup command being used in screenshot:
# Pull from git if enabled
if [[ -d .git && "{{PULL_START}}" == "1" ]]; then
  GIT_OUTPUT=$(git pull);
  echo "$GIT_OUTPUT";
fi;

# Build application
if [[ "{{BUILD_TRIGGER}}" == "Always" || ! -e "{{JAR_FILE}}" || ( "{{BUILD_TRIGGER}}" == "Git changes detected" && "$GIT_OUTPUT" != "Already up to date." ) ]]; then
  TOOL={{BUILD_TOOL}};

  # Automatic (detect)
  if [[ "$TOOL" == "Automatic" ]]; then
    if [[ -f gradlew ]]; then
      TOOL="Gradle";
    elif [[ -f mvnw ]]; then
      TOOL="Maven";
    else
      echo -e "\033[0;31mNo build tool detected (make sure your wrapper is set-up correctly)";
      exit 1;
    fi;
  fi;

  if [[ "$TOOL" == "Gradle" ]]; then
    # Gradle
    echo "Building with Gradle";
    chmod +x gradlew;
    ./gradlew build;
  elif [[ "$TOOL" == "Maven" ]]; then
    # Maven
    echo "Building with Maven";
    ./mvnw clean package;
  fi;
else
  echo "Skipping build";
fi;

# Get JAR file
FILE="{{JAR_FILE}}";
if [[ -d "{{JAR_FILE}}" ]]; then
  # Search given directory
  FILE=$(find "{{JAR_FILE}}" -name "*.jar" | head -n 1);
  echo "Found JAR file in {{JAR_FILE}}: $FILE";
fi;

# Start application
java -Xms128M -Xmx{{SERVER_MEMORY}}M -Dterminal.jline=false -Dterminal.ansi=true -jar "$FILE";
parkervcp added a commit that referenced this issue Aug 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Fix #261
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant