summaryrefslogtreecommitdiff
path: root/mix.exs
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2021-01-15 16:53:55 -0600
committerMark Felder <feld@feld.me>2021-01-15 16:53:55 -0600
commit3607dfefcae4a941c05f9e350354226d1c5fa920 (patch)
tree779d1cb7ca1769088c935327a126cb63fbd0e751 /mix.exs
parentcf367fdbd53b50f4324a01ddabdc0520cd787321 (diff)
Add mix alias to easily add copyright headers to files
Diffstat (limited to 'mix.exs')
-rw-r--r--mix.exs19
1 files changed, 18 insertions, 1 deletions
diff --git a/mix.exs b/mix.exs
index 14448f12f..166cbdca5 100644
--- a/mix.exs
+++ b/mix.exs
@@ -229,7 +229,8 @@ defmodule Pleroma.Mixfile do
"ecto.reset": ["ecto.drop", "ecto.setup"],
test: ["ecto.create --quiet", "ecto.migrate", "test"],
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
]
end
@@ -332,4 +333,20 @@ defmodule Pleroma.Mixfile do
|> Enum.filter(fn string -> string && string != "" end)
|> Enum.join()
end
+
+ defp add_copyright(_) do
+ line1 = "# Pleroma: A lightweight social networking server\\n"
+
+ line2 =
+ "# Copyright © 2017-#{NaiveDateTime.utc_now().year} Pleroma Authors <https://pleroma.social/>\\n"
+
+ line3 = "# SPDX-License-Identifier: AGPL-3.0-only\\n\\n"
+ template = line1 <> line2 <> line3
+
+ find = "find lib test priv -type f \\( -name '*.ex' -or -name '*.exs' \\) -exec "
+ grep = "grep -L '# Copyright' {} \\; |"
+ xargs = "xargs -n1 sed -i '' '1s;^;#{template};'"
+
+ :os.cmd(String.to_charlist("#{find}#{grep}#{xargs}"))
+ end
end