Commit ff60fe16405db76c5c3b389a9e59a63ab8ec1030

Thomas de Grivel 2022-11-03T14:30:51

mix licence

diff --git a/lib/header/c.ex b/lib/header/c.ex
index a9160c6..b58399a 100644
--- a/lib/header/c.ex
+++ b/lib/header/c.ex
@@ -1,15 +1,5 @@
-## kmxgit
+## update_header
 ## Copyright 2022 kmx.io <contact@kmx.io>
-##
-## Permission is hereby granted to use this software granted
-## the above copyright notice and this permission paragraph
-## are included in all copies and substantial portions of this
-## software.
-##
-## THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
-## PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
-## AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
-## THIS SOFTWARE.
 
 defmodule Header.C do
   def split(src) do
diff --git a/lib/header/cli.ex b/lib/header/cli.ex
index e69de29..8d2dae0 100644
--- a/lib/header/cli.ex
+++ b/lib/header/cli.ex
@@ -0,0 +1,3 @@
+## update_header
+## Copyright 2022 kmx.io <contact@kmx.io>
+
diff --git a/lib/header/make.ex b/lib/header/make.ex
index 673c058..5804d28 100644
--- a/lib/header/make.ex
+++ b/lib/header/make.ex
@@ -1,15 +1,5 @@
-## kmxgit
+## update_header
 ## Copyright 2022 kmx.io <contact@kmx.io>
-##
-## Permission is hereby granted to use this software granted
-## the above copyright notice and this permission paragraph
-## are included in all copies and substantial portions of this
-## software.
-##
-## THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
-## PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
-## AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
-## THIS SOFTWARE.
 
 defmodule Header.Make do
   def split(src) do
@@ -28,6 +18,10 @@ defmodule Header.Make do
         {acc, rest}
     end
   end
+  def split([], acc) do
+    acc = Enum.reverse(acc) |> Enum.join("\n")
+    {acc, ""}
+  end
 
   def main([src_path | dest_paths]) do
     {:ok, src} = File.read(src_path)
diff --git a/lib/mix/tasks/licence.ex b/lib/mix/tasks/licence.ex
index 8bbf0af..aec0405 100644
--- a/lib/mix/tasks/licence.ex
+++ b/lib/mix/tasks/licence.ex
@@ -1,4 +1,4 @@
-## kmxgit
+## update_header
 ## Copyright 2022 kmx.io <contact@kmx.io>
 
 defmodule Mix.Tasks.Licence do
@@ -8,6 +8,6 @@ defmodule Mix.Tasks.Licence do
     {ex_files, 0} = System.cmd("find", [".", "-name", "[a-z]*.ex",
                                         "-or", "-name", "[a-z]*.exs"])
     ex_files = ex_files |> String.split("\n") |> Enum.filter(& &1 != "")
-    UpdateHeader.update("mix.exs", ex_files)
+    UpdateHeader.update(["mix.exs" | ex_files])
   end
 end
diff --git a/lib/update_header.ex b/lib/update_header.ex
index 8d2bc16..752b755 100644
--- a/lib/update_header.ex
+++ b/lib/update_header.ex
@@ -1,3 +1,6 @@
+## update_header
+## Copyright 2022 kmx.io <contact@kmx.io>
+
 defmodule UpdateHeader do
 
   def main(_args) do
diff --git a/mix.exs b/mix.exs
index 6b881b2..9436308 100644
--- a/mix.exs
+++ b/mix.exs
@@ -7,11 +7,10 @@ defmodule UpdateHeader.MixProject do
   def project do
     [
       app: :update_header,
+      escript: [main_module: UpdateHeader],
       version: "0.1.0",
       elixir: "~> 1.14",
-      start_permanent: Mix.env() == :prod,
       deps: deps()
-      escript: [main_module: UpdateHeader]
     ]
   end
 
diff --git a/test/test_helper.exs b/test/test_helper.exs
index 869559e..938e604 100644
--- a/test/test_helper.exs
+++ b/test/test_helper.exs
@@ -1 +1,4 @@
+## update_header
+## Copyright 2022 kmx.io <contact@kmx.io>
+
 ExUnit.start()
diff --git a/test/update_header_test.exs b/test/update_header_test.exs
index 1916e23..dce4658 100644
--- a/test/update_header_test.exs
+++ b/test/update_header_test.exs
@@ -1,3 +1,6 @@
+## update_header
+## Copyright 2022 kmx.io <contact@kmx.io>
+
 defmodule UpdateHeaderTest do
   use ExUnit.Case
   doctest UpdateHeader