Skip to content

Instantly share code, notes, and snippets.

@fertapric
Last active June 1, 2017 14:47
Show Gist options
  • Save fertapric/35a25ee96708105092458264e15b2b04 to your computer and use it in GitHub Desktop.
Save fertapric/35a25ee96708105092458264e15b2b04 to your computer and use it in GitHub Desktop.
Handy alias to run an Elixir escript without building it. Quite useful for development.
defmodule MyAwesomeProject.Mixfile do
use Mix.Project
def project do
[app: :my_awesome_project,
version: "0.1.0",
elixir: "~> 1.3",
escript: escript(),
deps: deps(),
aliases: aliases()]
end
# Configuration for the escript
#
# Type "mix help escript.build" for more information
def escript do
[main_module: MyAwesomeProject.CLI]
end
# Configuration for the OTP application
#
# Type "mix help compile.app" for more information
def application do
# Specify extra applications you'll use from Erlang/Elixir
[extra_applications: [:logger]]
end
# Dependencies can be Hex packages:
#
# {:my_dep, "~> 0.3.0"}
#
# Or git/path repositories:
#
# {:my_dep, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
#
# Type "mix help deps" for more examples and options
defp deps do
[{:my_dep, "~> 0.3.0"}]
end
# Aliases are shortcuts or tasks specific to the current project.
# For example, to run the escript module:
#
# $ mix escript.run <args>
#
# See the documentation for `Mix` for more info on aliases.
defp aliases do
["escript.run": [&escript_run/1]]
end
defp escript_run(args) do
Mix.shell.cmd("mix run -e '#{escript()[:main_module]}.main(#{inspect(args)})'")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment