fs.watch with pull streams using chokidar
npm install --save pull-watch
var pull = require('pull-stream')
var watch = require('pull-watch')
var watcher = watch('./')
pull(
watcher.listen(),
pull.drain(function (event) {
console.log('event', event)
}, function (err) {
watcher.end()
})
)
where paths
is a files, dirs to be watched recursively, or glob patterns.
optional options are for chokidar
.
watch returns a pull-notify
stream with properties:
listen()
: function to create a pull source stream of the file watcher eventsabort(err)
: function to end the file watcher and signal an error to all respective streamsend()
: function to end the file watcher and signal completion to all respective streamsadd(path)
: function to add file path to file watcher
onReady(watcher)
is called on "ready" event.
The Apache License
Copyright © 2016 Michael Williams
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.