5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

mix nerves.new hogeのちょっとした改善プルリクがマージされた話(Elixir)

Last updated at Posted at 2020-10-06

はじめに

(本当に)ちょっとだけあれれ? なこと

$ mix nerves.new hoge
* creating hoge/config/config.exs
* creating hoge/config/target.exs
* creating hoge/lib/hoge.ex
* creating hoge/lib/hoge/application.ex
* creating hoge/test/test_helper.exs
* creating hoge/test/hoge_test.exs
* creating hoge/rel/vm.args.eex
* creating hoge/rootfs_overlay/etc/iex.exs
* creating hoge/.gitignore
* creating hoge/.formatter.exs
* creating hoge/mix.exs
* creating hoge/README.md

Fetch and install dependencies? [Yn] n
Your Nerves project was created successfully.

You should now pick a target. See https://hexdocs.pm/nerves/targets.html#content
for supported targets. If your target is on the list, set `MIX_TARGET`
to its tag name:

For example, for the Raspberry Pi 3 you can either
  $ export MIX_TARGET=rpi3
Or prefix `mix` commands like the following:
  $ MIX_TARGET=rpi3 mix firmware

If you will be using a custom system, update the `mix.exs`
dependencies to point to desired system's package.

Now download the dependencies and build a firmware archive:
  $ cd hoge
  $ mix deps.get
  $ mix deps.get
  $ mix firmware

If your target boots up using an SDCard (like the Raspberry Pi 3),
then insert an SDCard into a reader on your computer and run:
  $ mix firmware.burn

Plug the SDCard into the target and power it up. See target documentation
above for more information and other targets.
  • わかりますか?
  • Now download the dependencies and build a firmware archive:の下あたりで$ mix deps.getが2回でてきているのです :mask::mask:

気づいてしまったからには改善したほうがいいとおもってプルリクを出しました

  • プルリクを出してからなんと30分くらいでマージしてもらいました :tada::tada::tada:

スクリーンショット 2020-10-07 1.39.30.png

  • 私の黄色い猫のアイコンが左上と右下にいますよね!
  • 今回はElixirで書かれたコードを少し変えたコミットがマージしてもらえました
    • 以前、Nerves関連でプルリクをマージしてもらったことがあるのですがそのときはドキュメントだけでした
    • ソースコードのちょっとした修正ではありますが、Elixirのプログラムを修正したプルリクがマージしてもらえたのはとてもうれしくおもっておりますし、自信にもなりました
    • 以前ドキュメント修正したというプルリク → Update /CONTRIBUTING.md to /.github/CONTRIBUTING.md on README.md #501
  • 全体をみないとなんのことやらわからないとはおもいますが、差分は以下の通りです
@@ -215,15 +215,11 @@ defmodule Mix.Tasks.Nerves.New do
     install? = Mix.shell().yes?("\nFetch and install dependencies?")
 
     File.cd!(path, fn ->
-      extra =
-        if install? && Code.ensure_loaded?(Hex) do
-          cmd("mix deps.get")
-          []
-        else
-          ["  $ mix deps.get"]
-        end
+      if install? && Code.ensure_loaded?(Hex) do
+        cmd("mix deps.get")
+      end
 
-      print_mix_info(path, extra)
+      print_mix_info(path)
     end)
   end
 
@@ -255,8 +251,8 @@ defmodule Mix.Tasks.Nerves.New do
     end
   end
 
-  defp print_mix_info(path, extra) do
-    command = ["$ cd #{path}"] ++ extra
+  defp print_mix_info(path) do
+    command = ["$ cd #{path}"]
 
     Mix.shell().info("""
     Your Nerves project was created successfully.
  • いろいろ修正の方法があるとおもいました
  • print_mix_infoの第2引数のextraはそのまま残す修正の方法もあるとはおもいましたが、空のリストを渡すというような処理が増えることになりますし、プライベート関数で使われ方は限られていたので、思い切って第2引数のextraを消してしまうことにしました

nerves_bootstrapのプルリクを出すにあたってやったこと

  • READMEを読んで手元でビルドしたオレオレnerves_bootstrapをインストールした状態で、$ mix nerves.new hogeが正しく動作することを確認しました
  • あとはちょっとドキドキしながらプルリクを送ったらすぐにマージしてもらえました :tada::tada::tada:
$ cd nerves_bootstrap
$ mix test
$ mix do deps.get, archive.build, archive.install
$ cd ..
$ mix nerves.new hoge

Wrapping Up

  • なんかおかしいなとおもったら修正を検討してみよう!
  • 修正できたらプルリクしてみよう!
  • Enjoy Nerves !!!
  • Enjoy Elixir !!!
5
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?