From 3eb5c656b7f6bb8f2db1d62a2756a25473a10177 Mon Sep 17 00:00:00 2001 From: Todd Sedano Date: Fri, 8 Mar 2024 13:13:50 -0800 Subject: [PATCH] Add spring watch directions Co-authored-by: Ashley Willard Co-authored-by: Teal Stannard Co-authored-by: Perry Hertler --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index d9dd368..797ca42 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,19 @@ If you wish to use a different directory name, eg `components` instead of `packs If you want to have your packs code namespaced without adding a directory with the pack's name into the directory structure, you can use the [automatic namespaces gem](https://github.com/gap777/automatic_namespaces). +## Modify spring to detect pack moves + +If you use spring, when you move a pack, you'll want spring to update its cache + +Add this to one of your initializers +```ruby +Packs::Specification::Configuration.fetch.pack_paths.each do |dir| + Dir["#{dir}/package.yml"].each do |package_yml| + Spring.watch(package_yml) + end +end +``` + ### Splitting routes `packs-rails` allows you to split your application routes for every pack. You just have to create a file describing your routes and then `draw` them in your root `config/routes.rb` file (NOTE: the `draw` function is only in Rails 6.1+).