Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive watch for file pattern #102

Open
pellared opened this issue May 28, 2020 · 2 comments
Open

Recursive watch for file pattern #102

pellared opened this issue May 28, 2020 · 2 comments

Comments

@pellared
Copy link

pellared commented May 28, 2020

Hello,

I wanted to use the watcher to run make when a go file is modified.
Here is how I thought it would/should work:

watcher -cmd="make all" *.go

However it works only for current directory. It does not watch for changes that are in packages. Sample file structure:

.
├── c
│   └── g.go
├── foo.go
├── foo_test.go
├── go.mod
├── go.sum
├── Makefile

Test:

$:~/repos/seed$ watcher -list -cmd="make all" *.go
/home/rpajak/repos/seed/foo.go: foo.go
/home/rpajak/repos/seed/foo_test.go: foo_test.go

Watching 2 files

Notice that c/g.go is not being watched.

@pellared pellared changed the title Recursive watch for file patter Recursive watch for file pattern May 28, 2020
@deividaspetraitis
Copy link

One possible approach could be forming a list of *.go files to be fed to watcher, like following:

watcher -dotfiles=false -startcmd=true -cmd=watcher.sh $(find ../../ -type f -name \"*.go\" -exec echo {} \+)

However it has one downside however, to include newly created files you will need restart this process, which can be automated as well I believe.

@jonny-rimek
Copy link

I'm using the following cmd

 watcher -cmd="./build.sh" -pipe=true $(find $directory -type f -name "*.go" -not -path "./cdk.out/*" | tr '\n' ' ')

It will watch all go files in all subdirectories from your current dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants