Socket
Socket
Sign inDemoInstall

ignoring-watcher

Package Overview
Dependencies
120
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ignoring-watcher

Watch an entire directory tree while ignoring specific directories/files based on .gitignore rules.


Version published
Weekly downloads
208
decreased by-54.39%
Maintainers
1
Install size
3.45 MB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 12 Apr 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc