rerun

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2023 License: MIT Imports: 10 Imported by: 0

README

rerun: Re-run command on file system changes

Credit for this library goes to https://github.com/VojtechVitek/rerun

Lightweight file-watcher that re-runs given command on FS changes. It has simple CLI and optional config file. By default, it uses 200ms delay, which gives enough time for tools like git to update all directories/files within repository before killing the old process (when you switch branches etc).

In development. Only CLI MVP works right now.

Usage

rerun [-watch DIR...] [-ignore DIR...] -run COMMAND [ARG...]
Examples:
$ rerun -watch ./ -ignore vendor bin -run go run ./cmd/rerun/main.go
$ rerun -watch ./ -ignore vendor bin -run sh -c 'go build -i -o ./bin/rerun ./cmd/rerun/main.go && ./bin/rerun'
$ cd tests && rerun -watch '*_test.go' ../pkg -ignore vendor bin -run go test -run=Test

Installation

go get -u github.com/goware/rerun/cmd/rerun

You might need to download Go first.

api:
  watch:
    - cmd
    - *.go
  ignore:
    - bin
    - *_test.go
  cmd:
    - go run cmd/api/main.go -flags args

test-login:
  name: Test login
  watch:
    - tests/e2e
    - services/auth
    - data
  run:
    - go test -run=Login

Uses fsnotify behind the scenes, so technically it should work on most platforms including Linux, Mac OS and Windows.

License

Licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeSet

type ChangeSet struct {
	FirstFile string
	Files     map[string]struct{}
	Error     error
}

func (*ChangeSet) String

func (c *ChangeSet) String() string

type Command added in v0.0.6

type Command interface {
	Start() error
	Kill() error
	Wait() error
	PID() string
}

func StartCommand

func StartCommand(args ...string) (Command, error)

type DarwinCmd added in v0.0.6

type DarwinCmd struct {
	// contains filtered or unexported fields
}

func NewDarwinCmd added in v0.0.6

func NewDarwinCmd(args ...string) *DarwinCmd

func (*DarwinCmd) Kill added in v0.0.6

func (c *DarwinCmd) Kill() error

func (*DarwinCmd) PID added in v0.0.6

func (c *DarwinCmd) PID() string

func (*DarwinCmd) Start added in v0.0.6

func (c *DarwinCmd) Start() error

func (*DarwinCmd) String added in v0.0.6

func (c *DarwinCmd) String() string

func (*DarwinCmd) Wait added in v0.0.6

func (c *DarwinCmd) Wait() error

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

func NewWatcher

func NewWatcher() (*Watcher, error)

func (*Watcher) Add

func (w *Watcher) Add(paths ...string)

func (*Watcher) Close

func (w *Watcher) Close() error

func (*Watcher) Ignore

func (w *Watcher) Ignore(paths ...string)

func (*Watcher) Watch

func (w *Watcher) Watch(delay time.Duration) <-chan ChangeSet

type WindowsCmd added in v0.0.6

type WindowsCmd struct {
	// contains filtered or unexported fields
}

func NewWindowsCmd added in v0.0.6

func NewWindowsCmd(args ...string) *WindowsCmd

func (*WindowsCmd) Kill added in v0.0.6

func (c *WindowsCmd) Kill() error

func (*WindowsCmd) PID added in v0.0.6

func (c *WindowsCmd) PID() string

func (*WindowsCmd) Start added in v0.0.6

func (c *WindowsCmd) Start() error

func (*WindowsCmd) String added in v0.0.6

func (c *WindowsCmd) String() string

func (*WindowsCmd) Wait added in v0.0.6

func (c *WindowsCmd) Wait() error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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