0.0.13 • Published 7 years ago
observations v0.0.13
Be hesitatnt to try this at home. This tool is very wobbly.
$ yarn add -D observations
// ./observations.js
import Observations from 'observations'
Observations.register({
name: 'js-watcher',
match: ['./**/*.js', './**/*.jsx'],
ignore: './watch.config.js',
hanleError(error) {
// Apply whatever functionality you like when
// a process encounters an error.
console.log(`Got an error, dude!`)
},
handleOutput(output) {
// Apply whatever functionality you like when
// a managed process provides output.
console.log(`Got output, dude!`)
},
handleChange(change) {
// Apply whatever functionality you like when
// an observed path changes, and then programatically
// provide the next set of instructions.
change.exec([
'echo $VIRTUAL_HOST',
'ls ./public/css',
'webpack'
])
}
})
$ node observations
API
match: string[] = './**/*'
An array of globs/patterns to watch.
name: string = ''
optional Not yet used for anything.
ignore: string[] = ''
optional An array of globs/patterns to ignore.
persistent: boolean = true
optional Whether or not the process should exit on its own or stay alive.
handleOutput: (output: string)
optional A function to execute to handle process output.
handleError: (error: string)
optional A function to execute when process throws an error.
handleChange: (change: { data: string, exec: (commands: string[]) })
optional A function to execute when a watched file changes. handleChange
is provided with a change
object that contains data explaining the change
and an exec
method that allows you to provide which commands to execute
after your custom functionality has completed.