Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 134 lines (104 sloc) 6.202 kb
0a41966 @jslatts Updating docs
authored
1 # Stalker
e5d8e52 @jslatts Initial commit
authored
2
2bfb120 @jslatts Typos
authored
3 Stalker is a utility to watch a directory tree for incoming files. When if finds
06c4528 @jslatts Exclamation marks do not need periods after them!.
authored
4 one, it will fire off a callback function __OF YOUR CHOICE!__
8584b8c @jslatts Updating readme
authored
5
05d09c9 @jslatts Bug squashing. Ready for release.
authored
6 It should be smart enough to handle multiple files/folders being dropped into the
9733b9a @jslatts Updating readme
authored
7 directory being stalked.
8584b8c @jslatts Updating readme
authored
8
e5d8e52 @jslatts Initial commit
authored
9 ## Installation
10
0a41966 @jslatts Updating docs
authored
11 $ npm install stalker
e5d8e52 @jslatts Initial commit
authored
12
8584b8c @jslatts Updating readme
authored
13 ## How to use
14
15 var stalker = require('stalker');
16
17 stalker.watch('some_directory', function (err, file) {
18 console.log('I saw a file. It was going like this: ' + file);
19 });
20
7ce0bc3 @jslatts watcher-vows.js all passing
authored
21 ## Options
d30c1e6 @jslatts Adding optional batching mechanism.
authored
22
7ce0bc3 @jslatts watcher-vows.js all passing
authored
23 You can pass in a buffer time in milliseconds to make stalker batch up
d30c1e6 @jslatts Adding optional batching mechanism.
authored
24 the files and send them back in an array. The timer only starts when a new file
25 drops.
26
27 stalker.watch('./example', {buffer: 5000}, function(err, f) {
28 f.forEach(function _forEach(_f) {
29 console.log('I see ' + _f);
30 });
31 });
32
7ce0bc3 @jslatts watcher-vows.js all passing
authored
33 Setting recurse to false will keep stalker for walking down directories.
34
35 stalker.watch('./example', {recurse: false}, function(err, f) {
5cb44fe @jslatts Adding strict to readme
authored
36 console.log('I see ' + _f);
37 });
38
39 Setting strict to true will make stalker return for modified files.
40 *This has unpredictable behavior on windows/OSX. I have only used it
41 on Linux*
42
43 stalker.watch('./example', {strict: true}, function(err, f) {
44 console.log('I see ' + _f);
7ce0bc3 @jslatts watcher-vows.js all passing
authored
45 });
46
1af1780 @jslatts Adding remove callback. Switching tests to vows. Add more tests
authored
47 Stalker will also take a second callback that will be fired when files are removed:
48
5b780bc @jslatts fixing bad spacing in readme
authored
49 stalker.watch('./example', function(err, f) {
50 console.log('Added: ' + f);
51 }, function(err, f) {
52 console.log('Removed: ' + f);
53 });
1af1780 @jslatts Adding remove callback. Switching tests to vows. Add more tests
authored
54
80e0c6c @jslatts Making removal callbacks batch when in batch mode
authored
55 The removal callback also works in batch mode.
1af1780 @jslatts Adding remove callback. Switching tests to vows. Add more tests
authored
56
9733b9a @jslatts Updating readme
authored
57 ## Running tests
58
b787bb3 @jslatts Fixing some bugs in strict mode. Seems to work.
authored
59 I couldn't handle vows.js anymore. I ripped it out. Will replace with something
60 else in the future. For now, run example/*.js and play around adding and
61 removing files from the example directory:
9733b9a @jslatts Updating readme
authored
62
63 node example/test.js
64
e5d8e52 @jslatts Initial commit
authored
65 ## License
66
67 (The MIT License)
68
6aef70b @jslatts Reving to fix wrong docs
authored
69 Copyright (c) 2011 Justin Slattery (Justin.Slattery@fzysqr.com)
e5d8e52 @jslatts Initial commit
authored
70
71 Permission is hereby granted, free of charge, to any person obtaining
72 a copy of this software and associated documentation files (the
73 'Software'), to deal in the Software without restriction, including
74 without limitation the rights to use, copy, modify, merge, publish,
75 distribute, sublicense, and/or sell copies of the Software, and to
76 permit persons to whom the Software is furnished to do so, subject to
77 the following conditions:
78
79 The above copyright notice and this permission notice shall be
80 included in all copies or substantial portions of the Software.
81
82 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
83 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
84 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
85 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
86 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
87 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
88 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8584b8c @jslatts Updating readme
authored
89
90 ## Gir
97d40e5 @jslatts Better gir.
authored
91 :/::-.`
92 .o-```.:+o++//-
93 ++`````--------/o++:`
94 .o.````.-------------:++/:---------.`
95 ++````.-------------------+oo+++++//+oso/:.
96 ://o: `s-````-----------------------:oo- `-:+o+.--`
97 -+/::shy:-s````.-------:++++/:-------------+o: +/:/o`
98 /+::::hhhhy````-----:+++/:::::+++:------------/s- .::/`
99 o/::::ohhhh+``.----/o+::::::::::::+o:------------+o`
100 o/::::+dhhhd.`.---:o+::::::::::::::::s:------------:s/
101 +/::::/hhhhhs`----/o::::::::::::::::::/y-------------:ss`
102 -+::::/hhhhhh.----/o::::::::::::::::::::m+-----------/oooh-
103 o::::+hhhhhy.-----s::::::::::::::::::::sho---------:/oooooy/
104 .o:::shhhhho`-----:o:::::::::::::::::::odd/--------:+oooooooy/
105 .o/ohhhhhy:`.-----:s:::::::::::::::::/yhho--------/oooooooooy/
106 `------y-``-------o+::::::::::::::/shhh+-------:+ooooooooy+`
107 y``.:oo+:---/o/:::::::::/oyhhhs:-------/ooooooooys.
108 y``-y.o.+o----/ossooosyhhhhyo:-------:+ooooooosy-
109 y``++-/`-Nh------/+osssoo/:--------:/ooooooooy:
110 o-`-sNmhNMMo----------------------/+oooooooy+
111 `y`.-NMMMMMm--------------------/+oooooooyo`
112 :+`/MMMMMMh------------------/+oooooooyo`
113 :o.smNNds:---------------:/+oooooooyo.
114 .o/-------------------:/+oooooooy+`
115 .+o:-------------:/+oooooooss/`
116 :+o+:-----://+oooooooys+.
117 `:/+osyssoossyysohdo/`
118 `.----.` ./sds/.
119 .:oymho/:///`
120 `-`+-:sh:-o-:::/s
121 .o+ooos:/s/s:++:+s
122 +h/:yho+/:s/sooyd`
123 .s.:/ooss+yoy
124 /+-////o+soh`
125 `://o+.s/:--:/oyo`
126 .+++:s/. .//+y/:`
127 /+.-/y- :o+h
128 y`-:oy+ //--os/`
129 //+oysy` //.-:+oys+-
130 /+/++oyso:
131 `.`
132
8584b8c @jslatts Updating readme
authored
133
Something went wrong with that request. Please try again.