-
Notifications
You must be signed in to change notification settings - Fork 2
/
mix.exs
127 lines (113 loc) · 2.74 KB
/
mix.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
defmodule TidyEx.MixProject do
use Mix.Project
def project do
[
app: :tidy_ex,
version: "0.1.0-dev",
elixir: "~> 1.5",
compilers: [:tidy_ex_compile] ++ Mix.compilers(),
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
name: "TidyEx",
description: """
TidyEx corrects and cleans up HTML content by fixing markup errors. Elixir binding to the granddaddy of HTML tools (http://www.html-tidy.org/). Binding implemented as a C-Node based on the excellent example of Lukas Rieder's nodex.
""",
docs: docs(),
deps: deps(),
package: package()
]
end
defp docs do
[
main: "TidyEx"
]
end
def package do
[
maintainers: ["Frank Eickhoff"],
licenses: ["GNU LGPL"],
links: %{
"Github" => "https://github.com/f34nk/tidy_ex",
"Issues" => "https://github.com/f34nk/tidy_ex/issues",
"nodex" => "https://github.com/Overbryd/nodex",
"tidy-html5" => "https://github.com/htacg/tidy-html5"
},
files: [
"lib",
"target",
"test",
"priv/compile.sh",
"priv/clean.sh",
"priv/test.sh",
"mix.exs",
"README.md",
"LICENSE"
]
]
end
def application do
[
extra_applications: [:logger],
mod: {TidyEx.Safe, []},
# used to detect conflicts with other applications named processes
registered: [TidyEx.Safe.Cnode, TidyEx.Safe.Supervisor],
env: [
mode: TidyEx.Safe
]
]
end
defp deps do
[
# documentation helpers
{:ex_doc, ">= 0.0.0", only: :dev},
# cnode helpers
{:nodex, "~> 0.1.1"}
]
end
end
defmodule Shell do
def exec(exe, args, opts \\ [:stream]) when is_list(args) do
port =
Port.open(
{:spawn_executable, exe},
opts ++ [{:args, args}, :binary, :exit_status, :hide, :use_stdio, :stderr_to_stdout]
)
handle_output(port)
end
def handle_output(port) do
receive do
{^port, {:data, data}} ->
# Replace this with the appropriate broadcast
IO.binwrite(data)
handle_output(port)
{^port, {:exit_status, status}} ->
status
end
end
end
defmodule Mix.Tasks.Compile.TidyExCompile do
def run(_) do
if match?({:win32, _}, :os.type()) do
IO.warn("Windows is not supported yet.")
exit(1)
else
Shell.exec("priv/compile.sh", [])
end
:ok
end
def clean() do
Shell.exec("priv/clean.sh", [])
:ok
end
end
defmodule Mix.Tasks.Test.Target do
def run(_) do
if match?({:win32, _}, :os.type()) do
IO.warn("Windows is not supported yet.")
exit(1)
else
Shell.exec("priv/test.sh", [])
end
:ok
end
end