Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

once-file-changes

mattdesl17MIT1.0.0

fires callback when the glob/file changes

file, watch, once, one, event, change, all, add, io, watches, watcher

readme

once-file-changes

stable

Listens for file changes on the specified glob(s) and then fires a callback when something is changed or added. The watcher is then closed and no more callbacks will be fired.

var changes = require('once-file-changes')

changes('bundle.js', function(eventType, file) {
  //... do something now that the file has been added or changed
})

eventType is either add or change file is the file that was changed.

Usage

NPM

watcher = changes(glob, callback)

Listens for a single change/add event on glob and then triggers the callback once. Returns the watcher instance which you can close() yourself on timeout if no callback has been received.

glob defaults to wildcard *.

License

MIT, see LICENSE.md for details.