Pankaj Patel
Pankaj Patel

Pankaj Patel

Today's npm package: watchr

Today's npm package: watchr

Pankaj Patel's photo
Pankaj Patel
ยทJun 25, 2021ยท

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

Today's npm package is watchr

When creating CLI utilities, if you are dealing with files, would't it be great to be able to react to the file changes.

This package would help you do the same.

Here is how you can use this package to watch for currently open directory context

const watchr = require('watchr');

const listener = (change, path, newStats, oldStats) => {
  console.log(path, change);
  // or something more useful

const spy =
  (err) => {
    if(err) {
      return process.exit();
    console.log("now watching", process.cwd());

Stay tuned for tomorrow's package of the Day.

Share this