Skip to content

Commit

Permalink
Make oban installer idempotent (#1230)
Browse files Browse the repository at this point in the history
Using `on_exists: :skip` when generating the migration, it is safe for other igniter installers (like the one I'm working on)
to add `{:oban, "~> 2.0"}` to their `installs` list in their igniters. If oban is present, the installer does nothing, but if not the user gets a full oban installation.

Also removes an unnecessary `add_dep` call which prompts users to change the dep in cases where they have something like `~> 2.0` instead of exactly `~> 2.18`.
  • Loading branch information
zachdaniel authored Jan 27, 2025
1 parent b72c88c commit 55f7645
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/mix/tasks/oban.install.ex
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,11 @@ if Code.ensure_loaded?(Igniter) do
"""

igniter
|> Igniter.Project.Deps.add_dep({:oban, "~> 2.18"})
|> Igniter.Project.Config.configure("config.exs", app_name, [Oban], {:code, conf_code})
|> Igniter.Project.Config.configure("test.exs", app_name, [Oban], {:code, test_code})
|> Igniter.Project.Application.add_new_child({Oban, {:code, tree_code}}, after: [repo])
|> Igniter.Project.Formatter.import_dep(:oban)
|> Igniter.Libs.Ecto.gen_migration(repo, "add_oban", body: migration)
|> Igniter.Libs.Ecto.gen_migration(repo, "add_oban", body: migration, on_exists: :skip)

{:error, igniter} ->
igniter
Expand Down

0 comments on commit 55f7645

Please sign in to comment.