From 41501b7d34c74b842a79c4776e1fca40aa5d74ba Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 19 Sep 2019 17:16:47 -0500 Subject: [PATCH] Update entrypoint.sh (#2) * Update entrypoint.sh * Add JuliaFormatter at top of format.jl * Try different way of adding JuliaFormatter --- Dockerfile | 2 -- entrypoint.sh | 2 +- format.jl | 21 +++++++++++++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index f3c7f08..3c5adca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,8 +9,6 @@ LABEL "repository"="https://github.com/domluna/JuliaFormatter-action" LABEL "homepage"="https://github.com/domluna/JuliaFormatter-action" LABEL "maintainer"="Dominique Luna " -RUN julia -e 'using Pkg; Pkg.add("JuliaFormatter"); using JuliaFormatter' - COPY format.jl /format.jl COPY entrypoint.sh /entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh index 678b96b..d0f69f2 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,4 +2,4 @@ set -e set -o pipefail -/format.jl "$@" +julia format.jl "$@" diff --git a/format.jl b/format.jl index d76b443..111f548 100755 --- a/format.jl +++ b/format.jl @@ -1,7 +1,24 @@ #!/usr/bin/env julia -println(pwd()) -println(readdir()) +import Pkg + +if isfile("Project.toml") + # Okay, we're in $GITHUB_WORKSPACE, and we have a Julia package. + project = read("Project.toml", String) + if occursin("uuid = \"98e50ef6-434e-11e9-1051-2b60c6c9e899\"", project) + # This package is JuliaFormatter itself. Let's use the copy stored here + # instead of the last taged version + Pkg.add(Pkg.PackageSpec(path = pwd())) + else + # This is a package that's not JuliaFormatter. Just use the last tagged + # version of JuliaFormatter.jl. + Pkg.add("JuliaFormatter") + end +else + # This doesn't look like a standard Julia package, but it might be a script. + # In any case, it isn't JuliaFormatter.jl. + Pkg.add("JuliaFormatter") +end using JuliaFormatter