GitXplorerGitXplorer
r

node-watch

public
2 stars
5 forks
0 issues

Commits

List of commits on branch master.
Unverified
f9f5164e5165d3ac669bb778997da400baa3e20c

Merge pull request #1 from rafeca/feature-watch-new-files

jj-o-r committed 13 years ago
Unverified
b20c623a650a77c38078627bbbfd9eb56b50b5af

Fixed execution of tests from the Jake

rrafeca committed 13 years ago
Unverified
07af7a9bcb269c3598886c3f9751d3ea929b4c61

Add the feature of watch folder changes

rrafeca committed 13 years ago
Unverified
5638918dd1a10e7bb156a71c3b77bfc08562af9f

typo fixed

jj-o-r committed 14 years ago
Unverified
6547aedb5cc37c23acd667463030dfa0fbcff555

Clean npm package, updated docs

jj-o-r committed 14 years ago
Unverified
73353baf3fa61531f20cf5fa276ef41315a5f9c6

Issue with filewrite and specs

jj-o-r committed 14 years ago

README

The README file for this repository.

node-watch

Simple utility for nodejs to watch file changes a file change is a file whom's mtime is changed

This utility is handy for e.g. automatic testing in combination with a testing frame-work, An example lives within the JakeFile (jake and docco required)

run: jake autotest

and make changes in the src/watch/watch.js file or the spec/watchSpec.js file and see te specs running automaticly

Install:

 npm install nodewatch

(Use the "-g" global switch for installing nodewatch global)

Usage:

 var watch = require('nodewatch');
 // Adding 2 dirs relative from process.cwd()
 // Nested dirs are not watched
 // dirs can also be added absolute
 watch.add("./spec").add("./lib/watch").onChange(function(file,prev,curr){
    console.log(file);
    console.log(prev.mtime.getTime());
    console.log(curr.mtime.getTime());
 });
 
 // Clear (remove) the listeners
 watch.clearListeners();
 
 // Remove dirs to watch
 watch.remove("./spec").remdDir("./lib/watch");

Methods:

 // Add a dir or file relative from process.cwd()
 watch.add("./spec");
 // or
 watch.add("../spec");
 // or
 watch.add("../path/to/my/file.js")
 // Add a dir absolute
 watch.add("/absolute/path");
 
 // Set a listener
 // It will provide a file (filename as string), prev and curr stats objects
 watch.onChange(function(file,prev,curr){
        console.log(file);
        console.log(prev.mtime.getTime());
        console.log(curr.mtime.getTime());
  });
 
 // Remove a dir or file (absolute or relative)
 watch.remove("./spec");
 
 // Clear the listener(s) attached via onChange();
 watch.clearListeners();