Skip to content

Commit

Permalink
install nerves_tips package
Browse files Browse the repository at this point in the history
  • Loading branch information
mnishiguchi committed Dec 4, 2023
1 parent 88c5041 commit f636343
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 71 deletions.
62 changes: 0 additions & 62 deletions fortune/nerves-tips

This file was deleted.

16 changes: 9 additions & 7 deletions lib/nerves_motd.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule NervesMOTD do
@type option() ::
{:logo, IO.ANSI.ansidata()}
| {:extra_rows, [row()]}
| {:fortune, boolean()}
| {:show_fortune?, boolean()}

@typedoc """
One row of information
Expand All @@ -51,7 +51,7 @@ defmodule NervesMOTD do
an empty logo (`""`) to remove it completely.
* `:extra_rows` - a list of custom rows or a callback for returning rows.
The callback can be a 0-arity function reference or MFArgs tuple.
* `:fortune` - a boolean flag to show fortune.
* `:show_fortune?` - a boolean flag to show fortune.
"""
@spec print([option()]) :: :ok
def print(opts \\ []) do
Expand All @@ -66,7 +66,7 @@ defmodule NervesMOTD do
"\n",
Enum.map(rows(apps, combined_opts), &format_row/1),
"\n",
fortune(opts),
fortune(opts)
]
|> IO.ANSI.format()
|> IO.puts()
Expand All @@ -86,10 +86,12 @@ defmodule NervesMOTD do

@spec fortune([option()]) :: IO.ANSI.ansidata()
defp fortune(opts) do
if opts[:fortune] do
[Fortune.random!(), "n"]
else
[]
case Code.ensure_compiled(Fortune) do
{:module, fortune_mod} ->
if opts[:show_fortune?], do: [fortune_mod.random!(), "\n"], else: []

_ ->
[]
end
end

Expand Down
8 changes: 6 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule NervesMOTD.MixProject do
description: description(),
package: package(),
deps: deps(),
compilers: Mix.compilers() ++ [:fortune_compiler],
compilers: compilers(Mix.env()),
dialyzer: dialyzer(),
preferred_cli_env: %{
docs: :docs,
Expand All @@ -31,11 +31,15 @@ defmodule NervesMOTD.MixProject do
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]

defp compilers(env) when env in [:dev, :test], do: Mix.compilers() ++ [:fortune_compiler]
defp compilers(_), do: Mix.compilers()

defp deps do
[
{:nerves_runtime, "~> 0.8"},
{:nerves_time, "~> 0.4", optional: true},
{:fortune, "~> 0.1"},
{:nerves_tips, github: "nerves-project/nerves_tips", only: [:dev, :test], optional: true},
{:fortune, "~> 0.1", only: [:dev, :test], optional: true},
{:credo, "~> 1.5", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.1", only: :dev, runtime: false},
{:ex_doc, "~> 0.25", only: :docs, runtime: false},
Expand Down
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"nerves_runtime": {:hex, :nerves_runtime, "0.13.6", "aef9cb5e6232605d4e5421b297f41cde0535a53913c21e51c7ebe6c71c1b9cf6", [:mix], [{:nerves_logging, "~> 0.2.0", [hex: :nerves_logging, repo: "hexpm", optional: false]}, {:nerves_uevent, "~> 0.1.0", [hex: :nerves_uevent, repo: "hexpm", optional: false]}, {:uboot_env, "~> 1.0 or ~> 0.3.0", [hex: :uboot_env, repo: "hexpm", optional: false]}], "hexpm", "44b031f46542079d67d3ef0bd7b0c966e580909dd5cc61b7825a76e881e7cd5a"},
"nerves_time": {:hex, :nerves_time, "0.4.6", "f02e5e866149f3884a4b125104a5b677f7e61d271c1f7d87bc989197dc02dae5", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:muontrap, "~> 1.0 or ~> 0.5", [hex: :muontrap, repo: "hexpm", optional: false]}], "hexpm", "1fecb9e9dd098c0e93d35205a79e604831779f2d2313cfe7c31d181678e26ce6"},
"nerves_time_zones": {:hex, :nerves_time_zones, "0.3.3", "4d1c2e2d852efe239845b16d0bb99dcaa761b74a0da6e84f6a3c4c5006fbe994", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:zoneinfo, "~> 0.1.2", [hex: :zoneinfo, repo: "hexpm", optional: false]}], "hexpm", "46e260ebe0db65952a24d08fa8c2da6df5512ab22c567bde4f8cce60b7ff403a"},
"nerves_tips": {:git, "https://github.com/nerves-project/nerves_tips.git", "92e012d9885c7fa6406b8d6b29168cb459273ad1", []},
"nerves_uevent": {:hex, :nerves_uevent, "0.1.0", "651111a46be9a238560cbf7946989fc500e5f33d7035fd9ea7194d07a281bc19", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:property_table, "~> 0.2.0", [hex: :property_table, repo: "hexpm", optional: false]}], "hexpm", "cb0b1993c3ed3cefadbcdb534e910af0661f95c3445796ce8a7c8be3519a4e5f"},
"nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"},
"property_table": {:hex, :property_table, "0.2.4", "c53e3684b6da8cb77ceee89f8c7a980d6c626429a6653473db29c210b9d53103", [:mix], [], "hexpm", "feae0e06fee2740452dd8375eb2c3407ece12317525491345f141dcbe1b9442c"},
Expand Down

0 comments on commit f636343

Please sign in to comment.