Skip to content

Instantly share code, notes, and snippets.

@novaugust novaugust/mix.exs
Created Apr 22, 2015

Embed
What would you like to do?
Aliasing client tasks in your mix.exs
defmodule Operator.Mixfile do
use Mix.Project
alias Mix.Utilities.Client
defp aliases do
# Deps.get can't be put into a KWL easily
[
release: [&Client.compile/1, "release"],
ember: [&Client.compile/1]
]
|> Keyword.put(:"deps.get", [&Client.get_deps/1, "deps.get"])
|> Keyword.put(:"deps.compile", [&Client.compile/1, "deps.compile"])
|> Keyword.put(:"test.client", [&Client.test/1])
end
#....
end
defmodule Mix.Utilities.Client do
@client_cli_opts [cd: "client", into: IO.stream(:stdio, :line)]
def get_deps(_options) do
IO.puts "Installing client dependencies.."
{_, 0} = System.cmd("npm", ["install"], @client_cli_opts)
{_, 0} = System.cmd("bower", ["install"], @client_cli_opts)
IO.puts "Done"
end
def test(_options) do
IO.puts "Testing client...."
{_, 0} = System.cmd("npm", ["test"], @client_cli_opts)
IO.puts "Client tests pass."
end
def compile(_options) do
IO.puts "Compiling client assets."
emberCliPath = System.cwd() <> "/client/node_modules/ember-cli/bin/ember"
if Mix.env == :prod do
{_, 0} = System.cmd(emberCliPath, ["build", "--environment=production"], @client_cli_opts)
else
{_, 0} = System.cmd(emberCliPath, ["build"], @client_cli_opts)
end
end
end
@novaugust

This comment has been minimized.

Copy link
Owner Author

novaugust commented Apr 22, 2015

This code was written back in October 2014, so is pretty out of date with regards to elixir, phoenix, and ember, but works as an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.