Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,25 @@ COPY --from=jakolehm/nightwatch-arm64:1.0 /nightwatch /usr/bin

## Example Usage


#### Using `--find-cmd`:

```
$ nightwatch --find-cmd "find *.js" node app.js
```

#### Using `--files`:

```
$ nightwatch --files "package.json,src/" node app.js
```

#### Via `STDIN`:

```
$ find *.js | nightwatch node app.js
```

## Building From Source

```
Expand Down
11 changes: 10 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os/exec"
"os/signal"
"path/filepath"
"strings"
"syscall"
"time"

Expand Down Expand Up @@ -58,6 +59,7 @@ func main() {
exitOnError: c.Bool("exit-on-error"),
exitOnSuccess: c.Bool("exit-on-success"),
watchCmd: c.String("find-cmd"),
filesList: strings.Split(c.String("files"), ","),
}
go nightWatch.Run()

Expand All @@ -74,9 +76,13 @@ func main() {
},
&cli.StringFlag{
Name: "find-cmd",
Usage: "Command to list files to watch",
Usage: "Command to list files (or dirs) to watch",
Value: "find . -type f",
},
&cli.StringFlag{
Name: "files",
Usage: "Files (or dirs) to watch (comma separated list)",
},
&cli.IntFlag{
Name: "exit-on-error",
Usage: "Exit if process returns an error code.",
Expand Down Expand Up @@ -105,6 +111,7 @@ type processSignal struct {
type NightWatch struct {
cmd *exec.Cmd
watchCmd string
filesList []string
args cli.Args
cmdSignal chan *processSignal
watcher *fsnotify.Watcher
Expand All @@ -127,6 +134,8 @@ func (n *NightWatch) Run() {
if (stat.Mode() & os.ModeCharDevice) == 0 {
logrus.Debugln("reading files from stdin")
files = n.watchFromStdin()
} else if len(n.filesList) > 0 {
files = n.filesList
} else {
logrus.Debugf("Reading files from command: %s", n.watchCmd)
files = n.watchFromCmd()
Expand Down