Add a mix alias to bump copyright

This commit is contained in:
Mark Felder 2021-01-15 17:26:02 -06:00
parent 41a637c3a6
commit 23c6cea889
1 changed files with 11 additions and 1 deletions

12
mix.exs
View File

@ -230,7 +230,8 @@ defp aliases do
test: ["ecto.create --quiet", "ecto.migrate", "test"], test: ["ecto.create --quiet", "ecto.migrate", "test"],
docs: ["pleroma.docs", "docs"], docs: ["pleroma.docs", "docs"],
analyze: ["credo --strict --only=warnings,todo,fixme,consistency,readability"], analyze: ["credo --strict --only=warnings,todo,fixme,consistency,readability"],
copyright: &add_copyright/1 copyright: &add_copyright/1,
"copyright.bump": &bump_copyright/1
] ]
end end
@ -349,4 +350,13 @@ defp add_copyright(_) do
:os.cmd(String.to_charlist("#{find}#{grep}#{xargs}")) :os.cmd(String.to_charlist("#{find}#{grep}#{xargs}"))
end end
defp bump_copyright(_) do
year = NaiveDateTime.utc_now().year
find = "find lib test priv -type f \\( -name '*.ex' -or -name '*.exs' \\) |"
xargs = "xargs sed -i '' 's/# Copyright © 2017-20[0-9][0-9]/# Copyright © 2017-#{year}/'"
:os.cmd(String.to_charlist("#{find}#{xargs}"))
end
end end