Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including dir_watchdog with all npm packages installed. Try it out:

var dirWatchdog = require("dir_watchdog")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

dir_watchdog v1.0.0

This is a directory watchdog tool.

dir_watchdog

PayPayl donate button npm version fs version array-difference version readdirp version

  • This is a directory/folder watchdog tool.

Overview

Getting Started

npm install dir_watchdog

Usage

var dw = require('dir_watchdog');
var option = new Object();
option.rootpath = "./myfile";             //default path : "./"
option.timer = 1000;                        //default : 2000 millionseconds detect.
dw.watchdog(option, function(ret, files, dirs)
{
  //catch event msg.
  switch(ret)
  {
      case "init":
        showlog(ret, files, dirs);
        break;
      case "create":
        showlog(ret, files, dirs);
        break;
      case "delete":
        showlog(ret, files, dirs);
        break;
      case "change":
        showlog(ret, files, dirs);
        break;
      default:
        break;
  }
});
function showlog(ret, files, dirs)
{
    console.log(ret);
    console.log("=====files=====");
    console.log(files);
    console.log("=====directories=====");
    console.log(dirs);
}

Result

  • init:
* create: ( hello file)
* delete: ( hello file)
* change[rename]: ( hello -> hello_rename file)
* change[move]: ( ../myfile/hello_rename → ../myfile/test/hello__rename file)

License

  • SEE Linence
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free