watch folder is added using node

1k views Asked by At

i rewrote a example found here Watch a folder for changes using node.js, and print file paths when they are changed using chokidar

i want know when a folder is added to my folder (only interested in folders not files).

i rewrote the example to:

var chokidar = require('chokidar');

var watcher = chokidar.watch('\.\');

watcher
  .on('add', function(path) {console.log('File', path, 'has been added');})
  .on('change', function(path) {console.log('File', path, 'has been changed');})
  .on('unlink', function(path) {console.log('File', path, 'has been removed');})
  .on('error', function(error) {console.error('Error happened', error);})

whith no effect. when i add a new folder i get no message.

Operating System: Kubuntu 20.04

0

There are 0 answers