1.1.0 • Published 8 years ago

ignoring-watcher v1.1.0

Weekly downloads
2,645
License
ISC
Repository
github
Last release
8 years ago

ignoring-watcher

This module allows you to create a directory tree watcher while ignoring specific directories/files based on .gitignore rules. Instead of specifying which files/directories to watch it is often more convenient to specify which files/directories to not watch.

Internally, this module uses chokidar for cross-OS file watching. Also, the chokidar module internally uses anymatch to handle ignore rules.

Usage

var ignoringWatcher = require('ignoring-watcher').createWatcher({
    // Directory to watch. Defaults to process.cwd()
    dir: __dirname,

    // Watch multiple directories instead of a single dir
    dirs: ['some/dir', 'another/dir'],

    // One or more ignore patterns
    ignorePatterns: [
        '/node_modules',
        '*.marko.js'
    ],

    // The ignore patterns from these ignore files will all
    // be loaded and joined together
    ignoreFiles: [
        '.gitignore',
        '.npmignore'
    ],

    // Only the first existing ignore file (if any) will be loaded and merged
    selectIgnoreFile: [
        '.gitignore',
        '.npmignore'
    ],

    // If no ignore patterns were found via the other properties
    // then these ignore patterns will be used
    defaultIgnorePatterns: [
        '.*'
    ],

    // The following patterns will always be loaded and not impact
    // the loading of the `defaultIgnorePatterns`
    ignoreAlwaysPatterns: [
        'output-file.txt'
    ]
});

ignoringWatcher
    .on('modified', function(eventArgs) { // Fired for any change event (add, delete, etc.)
        var type = eventArgs.type; // add | addDir | change | unlink | unlinkDir
        var path = eventArgs.path; // The full file system path of the modified file
    });


ignoringWatcher.startWatching(); // Don't forget to start the file watching service

Maintainers

Contribute

Pull requests, bug reports and feature requests welcome.

License

ISC

1.1.0

8 years ago

1.0.14

9 years ago

1.0.13

9 years ago

1.0.12

9 years ago

1.0.11

9 years ago

1.0.10

9 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago