feat: patch README calendar with link to solution
This commit is contained in:
parent
c201f7ebe9
commit
df609c1bae
2 changed files with 12 additions and 2 deletions
|
@ -36,3 +36,5 @@ A behaviour for a solution to a puzzle. Must define a `solve/2` callback.
|
|||
## [`AdventOfCode.PuzzleCase`](./test/support/puzzle_case.ex)
|
||||
|
||||
Case template defining an `assert_solution/2` helper.
|
||||
|
||||
<!-- links -->
|
||||
|
|
|
@ -48,6 +48,16 @@ defmodule Mix.Tasks.AdventOfCode.Gen.Solution do
|
|||
create_file(part_test_file, part_test_contents)
|
||||
end
|
||||
|
||||
day_regex = ~r/\W(#{day})\W/
|
||||
readme_file = "README.md"
|
||||
readme_contents = File.read!("README.md")
|
||||
|
||||
readme_contents =
|
||||
"#{String.replace(readme_contents, day_regex, "[\\1]")}\n[#{day}]: ./#{day_file}\n"
|
||||
|
||||
File.write!(readme_file, readme_contents)
|
||||
Mix.shell().info([:green, "* updating ", :reset, "README.md"])
|
||||
|
||||
_ ->
|
||||
Mix.raise("Unknown arguments.")
|
||||
end
|
||||
|
@ -58,8 +68,6 @@ defmodule Mix.Tasks.AdventOfCode.Gen.Solution do
|
|||
@moduledoc """
|
||||
Day <%= @day %>
|
||||
"""
|
||||
|
||||
|
||||
end
|
||||
|
||||
defmodule <%= inspect(@mod) %>.Part1 do
|
||||
|
|
Loading…
Reference in a new issue