A plugin for manuel, which watches for changes in a directory and reacts with user-defined actions.
This plugin currently requires bash version 4 or higher.
Clone this repository into your manuel plugins directory ($HOME/.manuel.d/plugins by default):
$ cd ~/.manuel.d/plugins
$ git clone git://github.com/ShaneKilkelly/manuel-contrib-watch.git
First declare an associative array called actions
, of regex-patterns
to watch for and corresponding actions to take when a file matching
that pattern changes. Then call the manuel_watch
function with a
directory to watch over:
Example:
# In a manuelfile
load_plugin manuel-contrib-watch
function wait_for_change {
declare -A actions=(
[".*\.js$"]="echo 'we should concat and minify the js again'"
[".*\.go$"]="go build ."
)
manuel_watch .
}
The regex patterns should be compatible with the unix find
command.
In the above example, if the file ./assets/js/app.js
changes, the first item in
the actions
associative-array will match, and the corresponding command
string will be run.
- clarify that the actions array is declared by the caller, and is not 'passed in' to the task.
- remove dependency on
inotify-tools
, making themanuel_watch
task work on any unix system wherefind
and eithermd5
ormd5sum
are available.