elm-format
elm-format copied to clipboard
Explore using brew for Mac
Is anyone planning on writing a brew formula for this? Otherwise I could give it a try.
I don't know of anyone working on this. I would be happy to see this, but be warned that it's a bit painful because of the dependency on haskell. It also hopefully won't be needed for long because the goal for elm-format is to merge it into Elm-Platform within the next 3 months so that it will be distributed with Elm.
If you do want to look at this, here's a start that might help get haskell compilation working:
require "language/haskell"
class ElmFormat < Formula
include Language::Haskell::Cabal
desc "..."
homepage "..."
stable do
url "..."
sha256 "..."
end
bottle do
sha256 "..." => :el_capitan
sha256 "..." => :yosemite
sha256 "..." => :mavericks
end
head do
url "..."
end
depends_on "ghc" => :build
depends_on "cabal-install" => :build
def install
cabal_sandbox do
cabal_sandbox_add_source "elm-format"
cabal_install "--only-dependencies", "elm-format"
cabal_install "--prefix=#{prefix}", "elm-format"
end
end
test do
src_path = testpath/"Hello.elm"
src_path.write <<-EOS.undent
import Html exposing (text)
main = text "Hello, world!"
EOS
system bin/"elm-format", testpath/"Hello.elm", "--yes"
## assert output is formatted
end
end
I put this together with a little of help of what @avh4 posted above. https://github.com/enilsen16/homebrew/commit/85f95f82265c0bdcbd2a8cf69615b65e1afbffff
I am not sure homebrew will accept this formula until a stable version is released but I will try anyway. https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Acceptable-Formulae.md#stable-versions
The homebrew PRs, for reference:
- https://github.com/Homebrew/homebrew/pull/48624
- https://github.com/Homebrew/homebrew-devel-only/pull/41
- https://github.com/Homebrew/homebrew-devel-only/pull/40
If this is to become part of Elm Platform in the foreseeable future, there's no need to bother with Homebrew.
@avh4 what about the plans to move elm-format to the elm-platform?
As mentioned in https://github.com/avh4/elm-format/issues/84 it seems that brew support is partially working:
brew install --devel homebrew/devel-only/elm-format
After running that I got two elm-formats:
/usr/local/bin/elm-format-0.16
/usr/local/bin/elm-format-0.17
The only thing left to do was creating a symbolic link:
ln -s /usr/local/bin/elm-format-0.17 /usr/local/bin/elm-format
I just came here after using the formula as it seems to install 3 versions but link none. The formula should only install the latest version. If other versions are needed there should be secondary formulas to those version. Is there a reason for 3 version to be installed automatically and none be linked?
An elm-format formula exists for brew so I think this issue can be closed.
I have been using it for several years without issue (except for the lack of apple silicon support as discussed in https://github.com/avh4/elm-format/issues/723#issuecomment-1179513300).