Documentation
¶
Index ¶
Constants ¶
const DefaultBufSize = 10000
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config func(*RunCommand)
func KillOnChange ¶
func KillOnChange() Config
if killOnChange is true the running process will be killed, if there is a change
func MatchFiles ¶
type RunCommand ¶
type RunCommand struct {
// contains filtered or unexported fields
}
func New ¶
func New(watchDir, runCmd string, configs ...Config) *RunCommand
New creates a new RunCommand that runs runCmd on changes within watchDir or any of its subdirectories. No two instances of runCmd will be running at the same time. Before calling runCmd, the substring $_file will be replaced by the file path of the file that was created/modified and $_wd will be replaced by the path of watchDir. If runCmd does not contain the placeholder $_file, it will not just be called on file creation and file changes, but also when files are renamed of removed. Optional Configs are Stdout(): setting the stdout of the running process (default: os.Stdout) Stderr(): setting the stderr of the running process (default: os.Stderr) BufSize(): setting the buffer size of the reporting channels (default: DefaultBufSize) Ignore(): setting the regular expression to which matching files and directories are ignored (default: nil; ignore nothing) MatchFiles(): setting the regular expression to which file must match in order to be tracked (default: nil; all files match) Sleep(): setting the duration of sleeping time of two invocations of the running command (default: 0; no sleeping time)
func (*RunCommand) Run ¶
func (rc *RunCommand) Run(errors chan error) (Stoppable, error)
Run initiates the watching and running goroutines. Errors while watching are reported to the error channel. If the watcher or the observer could not be initialized properly, an error is returned. Otherwise the returned Stoppable can be used to terminate and kill the running process and end the observation