Skip to content

Instantly share code, notes, and snippets.

@bkeating
Created November 5, 2019 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bkeating/9d12a3df75143f509b5419f5e26aec7f to your computer and use it in GitHub Desktop.
Save bkeating/9d12a3df75143f509b5419f5e26aec7f to your computer and use it in GitHub Desktop.
nvAux - FIle System Storage Plugin
const chokidar = require('chokidar');
// Initialize watcher.
const watcher = chokidar.watch('/Users/kea1080/Documents/nmdiary', {
ignored: /(^|[\/\\])\../, // ignore dotfiles
persistent: true
});
// Something to use when events are received.
const log = console.log.bind(console);
// Add event listeners.
watcher
.on('add', path => log(`File ${path} has been added`))
.on('change', path => log(`File ${path} has been changed`))
.on('unlink', path => log(`File ${path} has been removed`));
// Get list of actual paths being watched on the filesystem
// setInterval(() => {
// var watchedPaths = watcher.getWatched();
// log(watchedPaths);
// }, 3000);
{
"name": "nv-storage-fs",
"version": "1.0.0",
"description": "file system superpowers",
"main": "index.js",
"author": "Ben Keating",
"license": "MIT",
"dependencies": {
"chokidar": "^3.3.0"
},
"prettier": {
"singleQuote": true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment