Skip to content

Commit

Permalink
ignored ids from file works only if the file is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
baldarn authored and remi committed Mar 19, 2024
1 parent 9b2aa9d commit 621747d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ $ mix deps.audit
| `--format` | String | `"human"` | The format of the report to generate (`"json"` or `"human"`) |
| `--ignore-advisory-ids` | String | `""` | Comma-separated list of advisory IDs to ignore |
| `--ignore-package-names` | String | `""` | Comma-separated list of package names to ignore |
| `--ignore-file` | String | `.mix-audit-skips` | Path of the ignore file |
| `--ignore-file` | String | `""` | Path of the ignore file |

## Example

Expand Down
16 changes: 10 additions & 6 deletions lib/mix_audit/cli/audit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ defmodule MixAudit.CLI.Audit do
|> Enum.map(&String.trim/1)
end

defp ignored_ids_from_file(opts) do
opts
|> Keyword.get(:ignore_file, ".mix-audit-skips")
|> File.read!()
|> String.split("\n")
|> Enum.reject(fn line -> String.starts_with?(line, "#") || String.trim(line) == "" end)
def ignored_ids_from_file(opts) do
case Keyword.get(opts, :ignore_file) do
nil ->
[]

ignore_file ->
File.read!(ignore_file)
|> String.split("\n")
|> Enum.reject(fn line -> String.starts_with?(line, "#") || String.trim(line) == "" end)
end
end
end

0 comments on commit 621747d

Please sign in to comment.