GitXplorerGitXplorer
r

node-watch

public
2 stars
5 forks
0 issues

Commits

List of commits on branch master.
Unverified
8b15e1c5e36986440780e2ff44ab3204ce7ce932

nodewatch as npm package added

jj-o-r committed 14 years ago
Unverified
a5ac3fa9c35479aab3a116f78387cbc7b50ff102

Usage changed, README too

jj-o-r committed 14 years ago
Unverified
8c6354cba19aa6363fc461be40a0b622c5ea7281

Simplified, api, usages and documentation

jj-o-r committed 14 years ago
Unverified
2a607b5e1c705bc13f56c6982104b3497888e756

minor changes

jj-o-r committed 14 years ago
Unverified
933bec090f5b2372171995ebbad49c49c65b0a1b

new dep watch.js

jj-o-r committed 14 years ago
Unverified
326f59edc78034f39d260c4c56537b282079ba65

Updated build, no JS mangle

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();