1.1.0 • Published 6 years ago

@jamen/watch-exec v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

@jamen/watch-exec

Watch files, execute commands, and stream the events.

Install

$ npm i -g @jamen/watch-exec

Usage

watch-exec --watch <glob> <command>

Watches the glob for changes then executes command, while streaming LDJSON events.

watch-exec --watch "src/**/*.js" "make js"
watch-exec --watch "src/**/*.js" "cat $FILE"

Or with multiple watchers:

watch-exec --watch "src/**/*.js" "make js" \
           --watch "src/**/*.css" "make css" \
           --watch "src/**/*.html" "make html"

Use $FILE inside the command string if you need access to the path.

Event stream

Events are Line-delimited JSON in the form [type, data]. The types being update and error. The events can be used by other tools (i.e. @jamen/reload-server):

watch-exec --watch "src/*.*" "make" | reload-server srv

watchExec(args, write, send)

A function that takes a process.argv array, write receives chunks of the commands' output, and a send handles the watch events.

watchExec(
    process.argv.slice(3),
    chunk => process.stderr.write(chunk),
    evt => client.send(JSON.stringify(evt))
})
1.1.0

6 years ago

1.0.0

6 years ago

0.2.0

7 years ago

0.1.0

7 years ago

0.0.0

7 years ago