uci-utils-watcher/example/example.js

29 lines
674 B
JavaScript

import Watcher from '../src/watcher'
import onDeath from 'ondeath'
(async () => {
let options = {
source:'./example/repo/**',
ignored:['**/dontwatch.js'],
ignoreList:['./example/repo/.gitignore'],
readyTimeout:null}
// let options = {source:'./readme.md'}
// let options = {source:'./example/*'}
let watcher = new Watcher(options)
await watcher.start()
watcher.on('changed',
(change) => {
console.log(`======= file ${change.file} was ${change.type} ==========`)
})
onDeath( () => {
console.log('\nHe\'s dead Jim')
watcher.remove()
})
})().catch(err => {
console.error('FATAL: UNABLE TO START SYSTEM!\n',err)
})