Make CartonFrontend dev
's file-watching opt-in to easily use it as a standalone CLI
#433
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
課題
現状、CartonFrontend devコマンドを単体で使う事ができません。
devコマンドのwatch機能が、devプラグインから呼び出されることに依存しているからです。
具体的には、devコマンドが変更検知をしてリビルドをする際には、
devプラグインが用意した名前付きパイプを使って依頼するからです。
提案
しかし、 devコマンドが単体で使えると便利です。
devコマンドの サーバ機能の動作だけを単体テストしやすくなるからです。
そこで、devコマンドにwatch対象を指定しなかった場合は、
watch機能を無効化して動作するようにします。
将来の目標
testコマンドが
test.js
を~/.carton
から配送しようとして失敗しているバグがあります。この変更を活用して、これを自動テストするつもりです。
実装
b48eb77
watchするときにその対象がターミナルに出力されるが、
その処理をdevコマンドから Server に移す。
実際に watch処理をやっているのは Serverであるため。
こうすると、他の箇所からも Server を利用してwatchする場合にログが出て便利。
なお、現状は他の利用箇所はない。
93dcdf5
パイプを受け取るコマンド引数をオプショナルにします。
ただし、watch対象ディレクトリが指定されている場合は省略を禁じます。