Skip to content

Instantly share code, notes, and snippets.

@sohelaman
Created July 2, 2019 03:50
Show Gist options
  • Save sohelaman/ed6a74faecd3ac49d5f4c557cd2baae0 to your computer and use it in GitHub Desktop.
Save sohelaman/ed6a74faecd3ac49d5f4c557cd2baae0 to your computer and use it in GitHub Desktop.

Revisions

  1. sohelaman created this gist Jul 2, 2019.
    20 changes: 20 additions & 0 deletions filesystem.node.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #!/usr/bin/env node

    const fs = require('fs');
    const chokidar = require('chokidar');

    chokidar
    .watch('.', {
    ignoreInitial: true,
    ignored: /(^|[\/\\])\../
    })
    .on('all', (event, path) => {
    console.log(event, path);
    let logfile = '~/Downloads/changes.log';
    let data = Math.floor(Date.now() / 1000) + ' | ' + event + ' | ' + path;
    fs.writeFile(logfile, data, err => {
    if (err) console.log(err);
    console.log("Successfully Written to File.");
    });
    })
    .on('ready', () => console.log('Initial scan complete. Ready for changes.'));