Asgard 0.5.0 adds dynamic task execution on file/directory changes
Asgard 0.5.0 adds a file watcher to the Ruby task runner. In a project’s .loki, watch :test, paths: %w[lib test], only: /\.rb\z/ declares which files a task cares about, and asgard watcher start runs one background process per project that reruns the task when they change.
Each trigger runs asgard <task> from the project root as a separate process with a fixed environment plus the changed paths in ASGARD_MODIFIED, ASGARD_ADDED and ASGARD_REMOVED; inside the task, changes.modified reads them back, and every list is empty when the task is run by hand, so one task body serves both. Different tasks run concurrently, the same task never overlaps itself, and a save during a long run queues behind it. asgard watcher list --all shows every project’s watches and each entry’s last exit, stop lets a running task finish, and saving a .loki restarts the watcher with the new declarations. File events come from the listen gem; the worker queue is ractor_queue, a native extension, so gem install asgard now compiles and needs a C++17 compiler. Ruby 3.2 or later. Docs: https://madbomber.github.io/asgard/watch/ and code at https://github.com/MadBomber/asgard.
Post a comment