From 2c2fdf1b2cf6c7ed85493b726f0b65db220cfba6 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Sun, 26 Apr 2020 16:51:15 +0300 Subject: [PATCH 1/2] --files option Signed-off-by: Jari Kolehmainen --- main.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index db1b429..c07af12 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "os/exec" "os/signal" "path/filepath" + "strings" "syscall" "time" @@ -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() @@ -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.", @@ -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 @@ -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() From cb5802f98d90ef85667354496f9230874986555c Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Sun, 26 Apr 2020 16:53:30 +0300 Subject: [PATCH 2/2] update examples Signed-off-by: Jari Kolehmainen --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 79deb64..3fddef9 100644 --- a/README.md +++ b/README.md @@ -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 ```