Ruby noob - rake タスクでガードを実行する必要がありますが、バックグラウンドで実行する方法が見つかりません。最後から2番目に実行する必要があるため、guard >
シェルがコマンドを待機していると、最後のタスクの実行が妨げられているためsh bundle exec guard
、rakeファイルを呼び出すことはオプションではありません. ドキュメントによると、これは機能するはずです:
##
desc "Watch files"
##
task :watcher do
Guard.setup
Guard::Dsl.evaluate_guardfile(:guardfile => 'Guardfile', :group => ['Frontend'])
Guard.guards('copy').run_all
end
#end watch files
https://github.com/guard/guard/wiki/Use-Guard-programmatically-cookbook
これが私の Guardfile の全文です (Rakefile と同じディレクトリにあります)。
# Any files created or modified in the 'source' directory
# will be copied to the 'target' directory. Update the
# guard as appropriate for your needs.
guard :copy, :from => 'src', :to => 'dist',
:mkpath => true, :verbose => true
しかしrake watcher
、エラーを返します:
07:02:31 - INFO - Using Guardfile at Guardfile.
07:02:31 - ERROR - Guard::Copy - cannot copy, no valid :to directories
rake aborted!
uncaught throw :task_has_failed
ここで言及するには多すぎるため、さまざまなハックを試しましたが、すべてが上記のGuard::copy - cannot copy, no valid :to directories
. ディレクトリはdist
確実に存在します。また、シェルから、rake 内または cmd ラインで Guard を呼び出すと、完全に実行されますが、guard >
シェルが残ります。私の問題はおそらくrakeファイルの構文エラーだと思いますか? 助けていただければ幸いです;)