watchspatch

command module
v0.0.0-...-a21937b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2021 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

watchspatch

watchspatch stands for watch and dispatch and is a filewatcher for moderately complex build workflows.

Think of a project where you'd have a couple frontend javascript files that may require being built, a couple go services etc... watchspatch allows you to watch the entire directory and subdirectory tree and depending on which file was modified, trigger a specific command.

I've found it to be a great companion to a make file when I have a couple different items to build (javascript, go, php all in one project), and some local docker-compose container to restart after build.

usage

Create a .watchspatch.toml at your project root. Here's an example:

version=1 # no choice for now it's always 1


# sometimes your editor might save a file twice in a row or save then `touch` it, triggering more events than wanted.
# `debounce` sets a global latency so that any pattern that was triggered can't be retriggered within `debounce` time of the previous event.
debounce="200ms"


# This is the most interesting part. You define glob patterns and if the file that got changed matches
# a given glob pattern, the corresponding command will be triggered
[patterns]
"*.go"={cmd = "echo toplevel"}
"*/*.js"={cmd = "echo sublevel"}
# Some commands will benefit from a custom debounce value (slow ones in general are a good fit here)
"**/*.php"={cmd = "echo any depth", debounce="1s"}
"go.sum"={cmd="echo gosum:::"}

Then run watchspatch from this directory. From now on any file event in that directory tree that matches one of the defined glob patterns will trigger a command.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址