Skip to content

Commit

Permalink
Add flag to include dev dependencies (#12)
Browse files Browse the repository at this point in the history
* Add dev deps flag

* switch order

Co-authored-by: Gergő Papp-Szentannai <gergo.papp-szentannai@ni.com>
  • Loading branch information
dschniepp and Gergő Papp-Szentannai authored May 26, 2021
1 parent 1f64bf3 commit f3377c3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ jobs:
if: ${{ matrix.lint }}

- run: mix test

- run: mix kudos.generate

- run: mix kudos.generate --dry-run

- run: mix kudos.generate --include-dev-deps
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ Print licenses to console:

`mix kudos.generate --dry-run`

Including dev dependencies:

`mix kudos.generate --include-dev-deps`

## Documentation

[https://hexdocs.pm/kudos](https://hexdocs.pm/kudos).
14 changes: 10 additions & 4 deletions lib/kudos.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ defmodule Kudos do
iex> Kudos.generate() |> String.length()
219
iex> Kudos.generate(false) |> String.length()
219
iex> Kudos.generate(true) |> String.length()
19050
"""
def generate do
load_deps_meta_data()
def generate(include_dev_deps \\ false) do
load_deps_meta_data(include_dev_deps)
|> Enum.reduce(header(), fn meta_data, resp ->
resp <> format(meta_data)
end)
Expand Down Expand Up @@ -94,7 +100,7 @@ defmodule Kudos do
"[#{key}](#{value})"
end

defp load_deps_meta_data() do
defp load_deps_meta_data(include_dev_deps) do
Mix.Dep.load_on_environment([])
|> Enum.map(fn dep ->
Mix.Dep.in_dependency(dep, fn _ ->
Expand All @@ -103,7 +109,7 @@ defmodule Kudos do
:umbrella

false ->
case is_prod?(dep) do
case include_dev_deps || is_prod?(dep) do
false ->
:dev

Expand Down
7 changes: 6 additions & 1 deletion lib/mix/tasks/kudos.generate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ defmodule Mix.Tasks.Kudos.Generate do
IO.puts("Generating Licenses file...")

resp =
Kudos.generate()
include_dev_deps?(args)
|> Kudos.generate()
|> handle_licenses(dry_run?(args))

case resp do
Expand All @@ -29,4 +30,8 @@ defmodule Mix.Tasks.Kudos.Generate do
defp dry_run?(args) do
Enum.member?(args, "--dry-run")
end

defp include_dev_deps?(args) do
Enum.member?(args, "--include-dev-deps")
end
end

0 comments on commit f3377c3

Please sign in to comment.