-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.js
47 lines (41 loc) · 1.14 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict';
require('mocha');
var fs = require('fs');
var assert = require('assert');
var glob = require('glob-fs');
var mkdirp = require('mkdirp');
var gitignore = require('./');
function has(files, fp) {
return files.indexOf(fp) !== -1;
}
describe('gitignore', function(done) {
var tempfiles = ['.foo', '.bar', '.baz'];
before(function() {
tempfiles.forEach(function(fp) {
fs.writeFileSync(fp, 'temp');
});
});
after(function() {
tempfiles.forEach(function(fp) {
fs.unlinkSync(fp);
});
});
it('should ignore files specified in `.gitignore` automatically:', function(done) {
glob()
.use(gitignore())
.readdir('*', function(err, files) {
assert.equal(has(files, '.DS_Store'), false);
done();
});
});
it('should not use `.gitignore` when `gitignore: false` is passed:', function(done) {
glob({ gitignore: false, dot: true })
.use(gitignore())
.readdir('*', function(err, files) {
assert.equal(has(files, '.foo'), true);
assert.equal(has(files, '.bar'), true);
assert.equal(has(files, '.baz'), true);
done();
});
});
});