https://github.com/bduffany/godemon
Automatically re-run a command when files change
https://github.com/bduffany/godemon
devserver file-watcher file-watchers go golang inotify nodemon
Last synced: 2 months ago
JSON representation
Automatically re-run a command when files change
- Host: GitHub
- URL: https://github.com/bduffany/godemon
- Owner: bduffany
- License: unlicense
- Created: 2022-02-17T16:06:27.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-03-09T17:31:13.000Z (over 1 year ago)
- Last Synced: 2024-04-24T05:16:23.233Z (over 1 year ago)
- Topics: devserver, file-watcher, file-watchers, go, golang, inotify, nodemon
- Language: Go
- Homepage:
- Size: 373 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
# godemon

[](http://unlicense.org/)godemon is a tool that runs a command, monitors for changes to files,
and restarts the command automatically whenever files change.It is great for:
- Restarting a development server whenever you change source code
- Running tests whenever you change source code
- Mirroring a directory to another location, using a tool like `rsync`
- Lots of other things!It is inspired by [nodemon](https://github.com/remy/nodemon) which
is a similar tool written in JavaScript.## Goals
- **Generic**: Does not give preference to any language or framework (even
Go). Can run arbitrary comands when changing arbitrary files.
- **Configurable**: There is no "one size fits all" approach to file
watchers, so godemon gives you fine-grained control over the paths that
are included or ignored. For more advanced users, it also lets you
control which signals are used to restart your process, since different
processes respond differently to different signals.
- **Strong defaults**: godemon ships with a default ignore list and also
treats `.gitignore` files as additional ignore patterns. These defaults
can be turned off via config options.## Status
godemon has been tested on Mac and Linux. It has not yet been tested on
Windows.The command line interface and config file format are not yet stable.
## Installation
The easiest way to install godemon is with the `go` CLI:
```bash
go install github.com/bduffany/godemon/cmd/godemon@latest
```## Basic usage
The `godemon` command can be used as follows:
```
godemon [options ...] [args ...]
```By default, the given command is executed whenever any file in the current
directory changes.## Examples
To watch the current directory (recursively) and run a command on any
change:```bash
godemon command
```To watch multiple directories, use `--watch` or `-w`. **When using this
flag, the current directory needs to be passed explicitly,** otherwise
it's assumed that you only want to watch `/some/other/dir` (in this
example).```bash
godemon --watch . --watch /some/other/dir command
```To only restart on changes to certain paths or patterns, use `--only` or
`-o`:```bash
godemon --only '*.ts' --only '*.tsx' command
```To ignore changes to certain paths or patterns, use `--ignore` or `-i`:
```bash
godemon --ignore '**/build/**' --ignore '**/dist/**' command
```## Default ignored patterns
The default ignored patterns are listed in
[default_ignore.go](https://github.com/bduffany/godemon/tree/master/default_ignore.go).To disable the default ignore list, pass `--no-default-ignore`.
By default, godemon also ignores patterns that are listed in `.gitignore`
files for any watched paths which are contained in a Git repository. To
disable this behavior, pass `--no-gitignore`.