Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a shell script as a mix alias

How can you run a shell script as a mix alias?

I've tried the following with no luck:

defp aliases() do
  [
    "test": [ "./scripts/test.sh" ]
  ]
end

defp aliases() do
  [
    "test": [ "scripts/test.sh" ]
  ]
end

Each returns with a variation of:

** (Mix) The task "./scripts/test" could not be found

like image 474
anthonator Avatar asked Apr 03 '18 16:04

anthonator


1 Answers

You can use invoke the Mix.Tasks.Cmd task for this:

"test": ["cmd ./scripts/test.sh"]
$ cat a.sh
#!/bin/bash
echo foo
$ cat mix.exs | grep test
      "test": ["cmd ./a.sh", "cmd echo bar"]
$ mix test
foo
bar
like image 50
Dogbert Avatar answered Nov 11 '22 05:11

Dogbert