1 | 'use strict';
|
2 |
|
3 | var gaze = require('../lib/gaze.js');
|
4 | var path = require('path');
|
5 | var fs = require('fs');
|
6 |
|
7 |
|
8 | function cleanUp(done) {
|
9 | [
|
10 | 'added.js',
|
11 | 'nested/added.js',
|
12 | ].forEach(function(d) {
|
13 | var p = path.resolve(__dirname, 'fixtures', d);
|
14 | if (fs.existsSync(p)) { fs.unlinkSync(p); }
|
15 | });
|
16 | done();
|
17 | }
|
18 |
|
19 | exports.patterns = {
|
20 | setUp: function(done) {
|
21 | process.chdir(path.resolve(__dirname, 'fixtures'));
|
22 | cleanUp(done);
|
23 | },
|
24 | tearDown: cleanUp,
|
25 | negate: function(test) {
|
26 | test.expect(1);
|
27 | gaze(['**/*.js', '!nested/**/*.js'], function(err, watcher) {
|
28 | watcher.on('added', function(filepath) {
|
29 | var expected = path.relative(process.cwd(), filepath);
|
30 | test.equal(path.join('added.js'), expected);
|
31 | watcher.close();
|
32 | });
|
33 |
|
34 | fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'nested', 'added.js'), 'var added = true;');
|
35 | setTimeout(function() {
|
36 |
|
37 | fs.writeFileSync(path.resolve(__dirname, 'fixtures', 'added.js'), 'var added = true;');
|
38 | }, 1000);
|
39 | watcher.on('end', test.done);
|
40 | });
|
41 | }
|
42 | };
|