Nestable Processes Mutate
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    este-watchpublic

    este-watch Build Status Dependency Status

    Fast and reliable Node.js files watcher.

    • It's fast, because it wraps fs.watch which does not use pooling.
    • It's reliable, because it supports only that behavior that works reliable across all OS's.

    Why yet another file watcher?

    There are zilions Node.js file watchers. No one is perfect. The most feature rich is probably gaze, but it burns CPU because it uses pooling fs.watchFile. This watcher uses only fs.watch so it has limited functionality (can't detect deleted files), but it works. And it's fast even for thousands of files. Read more here and here.

    Basic Usage

    Create a watcher to watch all files in the directories "foo" and "bar":

    function onWatch(file) {
      // Relative path to file that was changed or created
      console.log(file.filepath);
     
      // File Extension
      console.log(file.extension);
    }
     
    var esteWatch = require('este-watch');
     
    var watcher = esteWatch(['foo', 'bar'], onWatch);
     
    // Start the watcher
    watcher.start()

    Options

    A third argument can be passed to the esteWatch function to specify options.

    Three options are available:

    • filter: (RegExp) only fire watcher callback for files where the full relative filepath matches this pattern
    • ignoreFiles: (RegExp) prevent watcher callback from firing for files where the full relative filepath matches this pattern
    • ignoreDirectories: (RegExp) prevent watcher from even starting for directories where the full relative directory path matches this pattern
    esteWatch(['foo', 'bar'], onWatch, {
      filter: /\.js$/,
      ignoreFiles: /\.min\.js$/,
      ignoreDirectories: /node_modules/,
    }).start();

    install

    npm i este-watch

    Downloadsweekly downloads

    9

    version

    0.1.1

    license

    MIT

    repository

    githubgithub

    last publish

    collaborators

    • avatar