Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for creating file in subdirectories #103

Open
wants to merge 160 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
2bfc68d
Add platform and statpoll libs
shama Dec 31, 2013
847ed78
Initial implementation of platform
shama Dec 31, 2013
8d9f41f
Fix test, that pattern is actually not supposed to match those folders
shama Dec 31, 2013
ae5176a
More robust addLater matching test
shama Dec 31, 2013
97fb539
Add flatToTree helper for converting to old style tree
shama Dec 31, 2013
eda17f0
Add deps
shama Dec 31, 2013
a2f8913
Backwards compatibility: Return a tree of watched files/relative/unixify
shama Dec 31, 2013
4326ce8
Detect if no files have been matched and emit nomatch
shama Dec 31, 2013
ac7fd14
Handle rename events in platform
shama Dec 31, 2013
9ece356
Add banners
shama Dec 31, 2013
e20e21d
Clean up watch test
shama Dec 31, 2013
b20a7aa
Ensure we watch newly added files
shama Dec 31, 2013
46eeb3a
Handle safewrites once again :D
shama Dec 31, 2013
2b74ff4
Remove the old watch internals R.I.P.
shama Dec 31, 2013
ba61c10
clean up
shama Dec 31, 2013
f2b9a15
delay global no longer needed
shama Dec 31, 2013
0b2dfa7
Mine as well update the copyright to 2014 while Im here
shama Dec 31, 2013
4f1da66
Close out deleted filepaths (important for safewrites)
shama Dec 31, 2013
1a85ddc
Delay adding files to watch. Fixes duplicate handle race condition wi…
shama Jan 1, 2014
c3a6700
Remove no longer applicable tests
shama Jan 1, 2014
7bdbe06
Cleaner rename test
shama Jan 1, 2014
52a96f9
Fix for matching.addedLater test
shama Jan 1, 2014
e854f51
Fix for platform test
shama Jan 1, 2014
dedf453
Better test reset on platform tests
shama Jan 2, 2014
bbf430b
Fix helper for windows
shama Jan 4, 2014
7a536a6
Handle relative if unixify enabled
shama Jan 4, 2014
2537ed5
Unixify path sep for Windows tests
shama Jan 4, 2014
f306a8c
Unixify path sep on platform tests for Windows
shama Jan 4, 2014
7ba7723
Workaround for rename on linux
shama Jan 10, 2014
1142b66
Linux workarounds for platform
shama Jan 11, 2014
d768502
Unused var
shama Jan 11, 2014
2dd5397
Update to [email protected]
shama Jan 11, 2014
12be981
Use [email protected] if on [email protected]
shama Jan 11, 2014
b596d96
Fix safewrite test.
shama Jan 21, 2014
bcaba3f
Update pathwatcher and make optionalDependencies
shama Jan 21, 2014
131d866
If pathwatcher failed to install, just use gaze04. Closes GH-62.
shama Jan 22, 2014
30bfb98
Ignore experiments folder
shama Jan 22, 2014
0860f0f
Ignore platform test on node v0.8 as it will never be used there
shama Jan 22, 2014
dc837b8
Reset running upon closing watcher
shama Jan 22, 2014
909e199
Ignore errors thrown from optional dep
shama Jan 22, 2014
d3b0b15
Ignore globArray test on node v0.8
shama Jan 22, 2014
1baebd2
Get more info from travis
shama Jan 30, 2014
ee393f7
Fixes to platform for linux
shama Feb 17, 2014
7fbf960
Wait until all listeners are removed before finishing test. Closes GH…
tschaub Feb 4, 2014
0ae863a
Remove duplicate test.done()
shama Feb 18, 2014
54a8408
Remove unused var
shama Feb 18, 2014
28a777d
Trigger travis with more info
shama Feb 18, 2014
8e708d7
Remove unused var
shama Mar 3, 2014
32c2ce3
Ignoring tests on linux to come back to later. :'|
shama Mar 3, 2014
e7d1740
Remove test checking logging
shama Mar 3, 2014
4dd0a69
Fix ignore safewrite test on linux
shama Mar 20, 2014
fa22e68
More checks to find out why travis fails but local does not
shama Mar 20, 2014
27723e8
travis...
shama Mar 20, 2014
897732c
Travis...
shama Mar 20, 2014
8ec51bb
Sort results from this.relative as we dont care which order it returns
shama Mar 20, 2014
170ec61
setTimeout all the things :(
shama Mar 20, 2014
2699fb1
oops
shama Mar 20, 2014
90c9d8a
Ignoring test for now as it doesnt pass on travis, sigh
shama Mar 20, 2014
d1d9aac
Expose the platform mode
shama Mar 20, 2014
a5cff5c
Wait until all listeners are removed before finishing test. Closes GH…
tschaub Feb 4, 2014
390ac22
Defers emitting nomatch/ready events. Fixes GH-81. Closes GH-82.
amasad Feb 23, 2014
f9a5a56
Remove unneeded test, again
shama Mar 20, 2014
8f96ed6
Reapply patch d8f3699e405c96817b9ab05f3e251921bf1c14e0
shama Mar 20, 2014
6ebb57f
A little PR
shama Mar 20, 2014
50f37d8
EMFILE FAQ no longer necessary
shama Mar 20, 2014
b1cb69f
Remove duplicate and invalid test, again
shama Mar 20, 2014
82ba178
Update copyright to 2014
shama Mar 20, 2014
aa3ec84
Set platform.mode everytime before adding files to be watched
shama Mar 20, 2014
e3501e6
Fix typo
shama Mar 21, 2014
453cef8
Update FAQ and mention other great watch libraries
shama Mar 21, 2014
da8dd18
Call ready/nomatch with nextback. Fixes GH-77.
shama Mar 21, 2014
7c59b23
Add relative() benchmarks
shama Mar 21, 2014
d500589
Fix startup benchmark
shama Mar 21, 2014
8d3dd89
Better formatting on benchmarks
shama Mar 21, 2014
08109f3
Add benchmarker lib and smaller benchmarks
shama Mar 21, 2014
6ca69ab
Add changed benchmark
shama Mar 21, 2014
37807a6
Remove old broken benchmark. Fixes GH-33. Fixes GH-78.
shama Mar 21, 2014
0355f92
Remove unused grunt-benchmark
shama Mar 21, 2014
1bfa6a4
Update devDeps and grunt stuffs
shama Mar 21, 2014
b10129b
Add test specific for GH-85.
shama Mar 30, 2014
f4cf8bf
Update download count
shama Mar 30, 2014
46ceed8
Document cwd option. Fixes GH-85.
shama Mar 30, 2014
6d65161
Convert relative() to async. Ref GH-76.
shama Apr 9, 2014
7daf9ea
Change benchmark variable names a bit
shama Apr 9, 2014
ddedde0
Clean up
shama Apr 9, 2014
b111b60
Fix for relative on node v0.8
shama Apr 9, 2014
58d8e3e
Add gittip badge
shama Apr 9, 2014
bf7b9b2
Fix for node v0.8 relative
shama Apr 9, 2014
596571b
Better looking travis badge from shields.io
shama Apr 9, 2014
d745423
Ignore cwd (.add if needed)
Apr 9, 2014
5ee1ed8
Merge pull request #88 from oconnore/ignore-cwd
shama Apr 9, 2014
4cc9597
Replace blocking loops with async. Fixes GH-76.
shama Apr 9, 2014
1bf3b31
Always show stack traces
shama Apr 9, 2014
dfe5fea
Add test for symlinks to test ENOENT errors. Fixes GH-60. Fixes GH-45.
zeripath Dec 7, 2013
7d2949a
Refactor enoent symlink test a bit
shama Apr 9, 2014
6174f38
Add test for GH-88. Closes GH-89.
Apr 9, 2014
83c11e4
Use lstat instead of stat for symlinks
shama Apr 9, 2014
385419a
Ignore dontAddCwd test on node v0.8
shama Apr 9, 2014
1c55b3d
Test for patterns that start with ./ Closes GH-66.
shama Apr 10, 2014
6eac515
Ignore ENOENT with lstatSync
shama Apr 10, 2014
3a60f7c
Change relative . to ./ for consistency. Fixes GH-74.
shama Apr 10, 2014
907b2e9
Fix scope of try/catch
shama Apr 10, 2014
cb283f9
gaze04 ./ consistency
shama Apr 10, 2014
73d9b2e
Update async.forEachSeries and remove last callback. Thanks @contra!
shama Apr 10, 2014
8641558
Remove redundant nested function. Thanks @contra!
shama Apr 10, 2014
a730d6a
Fork pathwatcher
shama Apr 11, 2014
af9e85d
NanDispose -> NanDisposePersistent to remove deprecation warning
shama Apr 11, 2014
6156b93
Better check if pathwatcher was built
shama Apr 11, 2014
995f96c
Platform doesnt use opts
shama Apr 11, 2014
60e8d2f
Wrap platform to catch errors
shama Apr 11, 2014
2b07d96
Remove platform.error and better way to handle EMFILE
shama Apr 11, 2014
fa7ae8f
Remove last remnants of emfiled
shama Apr 11, 2014
20f0602
Specially handle EMFILE
shama Apr 11, 2014
45efb11
Set error code if EMFILE
shama Apr 11, 2014
a28feed
Dont completely ignore the error
shama Apr 11, 2014
8d163b5
Dont log to console
shama Apr 11, 2014
087c1b3
Fix example for this.watched in README
shama Apr 12, 2014
e76add9
Update copyright
shama Apr 12, 2014
96e8dff
Update readme error example
shama Apr 12, 2014
821e7c2
All constructor args are optional
shama Apr 12, 2014
d70e0f2
Make all constructor args optional
shama Apr 12, 2014
69f1746
Remove unneeded _platform wrapper
shama Apr 12, 2014
c23834b
Make constructor args optional in gaze04
shama Apr 12, 2014
5187928
Use a better formatted EMFILE error
shama Apr 12, 2014
d888c7f
Add default error listeners to call callback rather than throw error
shama Apr 12, 2014
9b992ad
Stop on errors in the benchmarks
shama Apr 12, 2014
1ad23a9
Add note about EMFILE errors
shama Apr 12, 2014
5652b4d
Fix ready callback API
shama Apr 12, 2014
1a4bf36
README nitpicks
shama Apr 12, 2014
0e46a4d
Fix some jshint errors
shama Apr 12, 2014
fcaecad
Only fallback to stat poll if not forced in watch mode
shama Apr 12, 2014
eb44e0f
Update AUTHORS
shama Apr 12, 2014
81e37ad
Update AUTHORS
shama Apr 12, 2014
409e30d
Add github pathwatcher contributors to AUTHORS
shama Apr 12, 2014
bfe97f0
Update CHANGELOG for 0.6.0
shama Apr 13, 2014
1fc7f14
Update package.json
shama Apr 13, 2014
b739833
v0.6.0
shama Apr 13, 2014
27d3705
Fix for absolute paths
shama Apr 14, 2014
588fe80
v0.6.1
shama Apr 14, 2014
336bfe3
Fix argument error with watched()
shama Apr 14, 2014
6cbec85
Add test specifically for watched()
shama Apr 14, 2014
ed7c6d0
Fix for erroneous added events on folders
shama Apr 14, 2014
2eb1fe6
Fix tests, **/*.js should not match folders that are not named *.js
shama Apr 14, 2014
7e5e719
Ignore 4244 warnings from msvs as well. Fixes GH-92.
shama Apr 14, 2014
c0a752d
Simplify test
shama Apr 14, 2014
2586e8d
Ignore more tests on node v0.8 as wontfix
shama Apr 14, 2014
67102ff
v0.6.2
shama Apr 14, 2014
0f89570
Use deprecated NanDispose for node v0.11 compatibility. Fixes GH-93.
shama Apr 15, 2014
fb7861e
Add official support for node v0.11
shama Apr 15, 2014
bf76191
v0.6.3
shama Apr 15, 2014
e870108
Fix typo in README
shama Apr 15, 2014
cfc39be
Catch and emit error in readdir
Apr 15, 2014
5ec5e1c
Merge pull request #95 from oconnore/error-catch
shama Apr 15, 2014
7aa0bac
Dont officially care about node v0.11 yet
shama Apr 15, 2014
4141cdc
Fix for 0 maxListeners
shama Apr 15, 2014
400382e
nextTick benchmark runs
shama Apr 17, 2014
dc76589
Use graceful-fs.
shama Apr 17, 2014
6ec2bff
Determine whether pathwatcher built without running it. Ref GH-98.
shama Apr 17, 2014
faff6fb
Only init pathwatcher when a file is watched. Fixes GH-98.
shama Apr 19, 2014
95c6737
Test for creating file in subdirectories
floatdrop Apr 20, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/node_modules/
node_modules
experiments
build
9 changes: 9 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ Chris Chua (http://sirh.cc/)
Kael Zhang (http://kael.me)
Krasimir Tsonev (http://krasimirtsonev.com/blog)
brett-shwom
Kai Groner
zeripath
Tim Schaub (http://tschaub.net/)
Amjad Masad (http://amasad.github.com/)
Eric Schoffstall (http://contra.io/)
Eric O'Connor (http://oco.nnor.org/)
Cheng Zhao (https://github.com/zcbenz)
Kevin Sawicki (https://github.com/kevinsawicki)
Nathan Sobo (https://github.com/nathansobo)
24 changes: 5 additions & 19 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
module.exports = function(grunt) {
'use strict';

grunt.option('stack', true);

grunt.initConfig({
benchmark: {
all: {
src: ['benchmarks/*.js'],
options: { times: 10 }
}
},
nodeunit: {
files: ['test/*_test.js'],
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
gruntfile: {
src: 'Gruntfile.js'
},
lib: {
src: ['lib/**/*.js']
},
test: {
src: ['test/**/*_test.js']
},
options: { jshintrc: true },
all: ['Gruntfile.js', 'lib/**/*.js', 'test/*.js', 'benchmarks/*.js', '!lib/pathwatcher.js'],
},
});

Expand All @@ -32,7 +19,6 @@ module.exports = function(grunt) {
grunt.task.run('nodeunit');
});

grunt.loadNpmTasks('grunt-benchmark');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.registerTask('default', ['jshint', 'nodeunit']);
Expand Down
2 changes: 1 addition & 1 deletion LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013 Kyle Robinson Young
Copyright (c) 2014 Kyle Robinson Young

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
83 changes: 60 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
# gaze [![Build Status](https://travis-ci.org/shama/gaze.png?branch=master)](https://travis-ci.org/shama/gaze)
# gaze [![Build Status](http://img.shields.io/travis/shama/gaze.svg)](https://travis-ci.org/shama/gaze) [![gittip.com/shama](http://img.shields.io/gittip/shama.svg)](https://www.gittip.com/shama)

A globbing fs.watch wrapper built from the best parts of other fine watch libs.
Compatible with Node.js 0.10/0.8, Windows, OSX and Linux.

![gaze](http://dontkry.com/images/repos/gaze.png)

## Features

[![NPM](https://nodei.co/npm/gaze.png?downloads=true)](https://nodei.co/npm/gaze/)

* Consistent events on OSX, Linux and Windows
* Very fast start up and response time
* High test coverage
* Uses native OS events but falls back to stat polling
* Option to force stat polling with special file systems such as networked
* Downloaded over 400K times a month
* Used by [Grunt](http://gruntjs.com), [gulp](http://gulpjs.com), [Tower](http://tower.github.io/) and many others

## Usage
Install the module with: `npm install gaze` or place into your `package.json`
and run `npm install`.
Expand All @@ -18,7 +30,9 @@ gaze('**/*.js', function(err, watcher) {
// watcher === this

// Get all watched files
console.log(this.watched());
this.watched(function(watched) {
console.log(watched);
});

// On file changed
this.on('changed', function(filepath) {
Expand All @@ -41,7 +55,9 @@ gaze('**/*.js', function(err, watcher) {
});

// Get watched files with relative paths
console.log(this.relative());
this.relative(function(err, files) {
console.log(files);
});
});

// Also accepts an array of patterns
Expand All @@ -68,21 +84,36 @@ gaze.on('all', function(event, filepath) { });
### Errors

```javascript
gaze('**/*', function() {
this.on('error', function(err) {
// Handle error here
});
gaze('**/*', function(error, watcher) {
if (error) {
// Handle error if it occurred while starting up
}
});

// Or with the alternative interface
var gaze = new Gaze();
gaze.on('error', function(error) {
// Handle error here
});
gaze.add('**/*');
```

#### `EMFILE` errors

By default, gaze will use native OS events and then fallback to slower stat polling when an `EMFILE` error is reached. Gaze will still emit or return the error as the first argument of the ready callback for you to handle.

It is recommended to advise your users to increase their file descriptor limits to utilize the faster native OS watching. Especially on OSX where the default descriptor limit is 256.

In some cases, native OS events will not work. Such as with networked file systems or vagrant. It is recommended to set the option `mode: 'poll'` to always stat poll for those situations.

### Minimatch / Glob

See [isaacs's minimatch](https://github.com/isaacs/minimatch) for more
information on glob patterns.

## Documentation

### gaze(patterns, [options], callback)
### gaze([patterns, options, callback])

* `patterns` {String|Array} File patterns to be matched
* `options` {Object}
Expand All @@ -92,7 +123,7 @@ information on glob patterns.

### Class: gaze.Gaze

Create a Gaze object by instanting the `gaze.Gaze` class.
Create a Gaze object by instancing the `gaze.Gaze` class.

```javascript
var Gaze = require('gaze').Gaze;
Expand All @@ -105,6 +136,8 @@ var gaze = new Gaze(pattern, options, callback);
* `interval` {integer} Interval to pass to fs.watchFile
* `debounceDelay` {integer} Delay for events called in succession for the same
file/event
* `mode` {string} Force the watch mode. Either `'auto'` (default), `'watch'` (force native events), or `'poll'` (force stat polling).
* `cwd` {string} The current working directory to base file patterns from. Default is `process.cwd()`.

#### Events

Expand All @@ -126,33 +159,37 @@ var gaze = new Gaze(pattern, options, callback);
* `add(patterns, callback)` Adds file(s) patterns to be watched.
* `remove(filepath)` removes a file or directory from being watched. Does not
recurse directories.
* `watched()` Returns the currently watched files.
* `relative([dir, unixify])` Returns the currently watched files with relative paths.
* `watched([callback])` Returns the currently watched files.
* `callback` {function} Calls with `function(err, files)`.
* `relative([dir, unixify, callback])` Returns the currently watched files with relative paths.
* `dir` {string} Only return relative files for this directory.
* `unixify` {boolean} Return paths with `/` instead of `\\` if on Windows.
* `callback` {function} Calls with `function(err, files)`.

## FAQs

### Why Another `fs.watch` Wrapper?
I liked parts of other `fs.watch` wrappers but none had all the features I
needed. This lib combines the features I needed from other fine watch libs:
Speedy data behavior from
[paulmillr's chokidar](https://github.com/paulmillr/chokidar), API interface
from [mikeal's watch](https://github.com/mikeal/watch) and file globbing using
[isaacs's glob](https://github.com/isaacs/node-glob) which is also used by
[cowboy's Grunt](https://github.com/gruntjs/grunt).

### How do I fix the error `EMFILE: Too many opened files.`?
This is because of your system's max opened file limit. For OSX the default is
very low (256). Increase your limit temporarily with `ulimit -n 10480`, the
number being the new max limit.
needed when this library was originally written. This lib once combined the features I needed from other fine watch libs
but now has taken on a life of it's own (**gaze doesn't wrap `fs.watch` or `fs.watchFile` anymore**).

Other great watch libraries to try are:

* [paulmillr's chokidar](https://github.com/paulmillr/chokidar)
* [mikeal's watch](https://github.com/mikeal/watch)
* [github's pathwatcher](https://github.com/atom/node-pathwatcher)
* [bevry's watchr](https://github.com/bevry/watchr)

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style.
Add unit tests for any new or changed functionality. Lint and test your code
using [grunt](http://gruntjs.com/).

## Release History
* 0.6.3 - Add support for node v0.11
* 0.6.2 - Fix argument error with watched(). Fix for erroneous added events on folders. Ignore msvs build error 4244.
* 0.6.1 - Fix for absolute paths.
* 0.6.0 - Uses native OS events (fork of pathwatcher) but can fall back to stat polling. Everything is async to avoid blocking, including `relative()` and `watched()`. Better error handling. Update to [email protected]. No longer watches `cwd` by default. Added `mode` option. Better `EMFILE` message. Avoids `ENOENT` errors with symlinks. All constructor arguments are optional.
* 0.5.1 - Use setImmediate (process.nextTick for node v0.8) to defer ready/nomatch events (@amasad).
* 0.5.0 - Process is now kept alive while watching files. Emits a nomatch event when no files are matching.
* 0.4.3 - Track file additions in newly created folders (@brett-shwom).
Expand All @@ -176,5 +213,5 @@ using [grunt](http://gruntjs.com/).
* 0.1.0 - Initial release

## License
Copyright (c) 2013 Kyle Robinson Young
Copyright (c) 2014 Kyle Robinson Young
Licensed under the MIT license.
70 changes: 70 additions & 0 deletions benchmarks/benchmarker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
'use strict';

var async = require('async');
var fs = require('fs');
var rimraf = require('rimraf');
var path = require('path');
var AsciiTable = require('ascii-table');
var readline = require('readline');

function Benchmarker(opts) {
if (!(this instanceof Benchmarker)) return new Benchmarker(opts);
opts = opts || {};
this.table = new AsciiTable(opts.name || 'benchmark');
this.tmpDir = opts.tmpDir || path.resolve(__dirname, 'tmp');
var max = opts.max || 2000;
var multiplesOf = opts.multiplesOf || 100;
this.fileNums = [];
for (var i = 0; i <= max / multiplesOf; i++) {
this.fileNums.push(i * multiplesOf);
}
this.startTime = 0;
this.files = [];
}
module.exports = Benchmarker;

Benchmarker.prototype.log = function() {
readline.cursorTo(process.stdout, 0, 0);
readline.clearScreenDown(process.stdout);
this.table.addRow.apply(this.table, arguments);
console.log(this.table.toString());
};

Benchmarker.prototype.setup = function(num) {
this.teardown();
fs.mkdirSync(this.tmpDir);
this.files = [];
for (var i = 0; i <= num; i++) {
var file = path.join(this.tmpDir, 'test-' + i + '.txt');
fs.writeFileSync(file, String(i));
this.files.push(file);
}
};

Benchmarker.prototype.teardown = function() {
if (fs.existsSync(this.tmpDir)) {
rimraf.sync(this.tmpDir);
}
};

Benchmarker.prototype.run = function(fn, done) {
var self = this;
async.eachSeries(this.fileNums, function(num, next) {
self.setup(num);
fn(num, function() {
process.nextTick(next);
});
}, function() {
self.teardown();
done();
});
};

Benchmarker.prototype.start = function() {
this.startTime = process.hrtime();
};

Benchmarker.prototype.end = function(radix) {
var diff = process.hrtime(this.startTime);
return ((diff[0] * 1e9 + diff[1]) * 0.000001).toFixed(radix || 2).replace(/\d(?=(\d{3})+\.)/g, '$&,') + 'ms';
};
27 changes: 27 additions & 0 deletions benchmarks/changed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

var gaze = require('../');
var path = require('path');
var fs = require('fs');
var Benchmarker = require('./benchmarker');

var b = new Benchmarker({ name: path.basename(__filename) });
b.table.setHeading('files', 'ms').setAlign(0, 2).setAlign(1, 2);
b.run(function(num, done) {
gaze('**/*', {cwd: b.tmpDir, maxListeners:0}, function(err, watcher) {
if (err) {
console.error(err.code + ': ' + err.message);
return process.exit();
}
watcher.on('changed', function() {
b.log(num, b.end());
watcher.close();
});
watcher.on('end', done);
var randFile = path.join(b.tmpDir, 'test-' + Math.floor(Math.random() * num) + '.txt');
b.start();
fs.writeFileSync(randFile, '1234');
});
}, function() {
process.exit();
});
46 changes: 0 additions & 46 deletions benchmarks/gaze100s.js

This file was deleted.

Loading