/
config-flags-gulpfile.js
88 lines (74 loc) · 2.31 KB
/
config-flags-gulpfile.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
'use strict';
var expect = require('expect');
var path = require('path');
var fixturesDir = path.join(__dirname, 'fixtures/config');
var headLines = require('gulp-test-tools').headLines;
var runner = require('gulp-test-tools').gulpRunner().basedir(fixturesDir);
describe('config: flags.gulpfile', function() {
it('Should configure with a .gulp.* file', function(done) {
runner
.chdir('flags/gulpfile')
.gulp()
.run(cb);
function cb(err, stdout, stderr) {
stdout = headLines(stdout, 2, 2);
expect(stdout).toEqual(
'This gulpfile : ' +
path.join(fixturesDir, 'flags/gulpfile/is/here/mygulpfile.js') +
'\n' +
'The current directory : ' + path.join(fixturesDir, 'flags/gulpfile')
);
expect(stderr).toEqual('');
done(err);
}
});
it('Should configure with a .gulp.* file in the directory specified by ' +
'\n\t--cwd', function(done) {
runner
.gulp('--cwd ./flags/gulpfile')
.run(cb);
function cb(err, stdout, stderr) {
stdout = headLines(stdout, 2, 3);
expect(stdout).toEqual(
'This gulpfile : ' +
path.join(fixturesDir, 'flags/gulpfile/is/here/mygulpfile.js') +
'\n' +
'The current directory : ' + path.join(fixturesDir, 'flags/gulpfile')
);
expect(stderr).toEqual('');
done(err);
}
});
it('Should ignore a ./gulp.* file if another directory is specified by ' +
'\n\t--cwd', function(done) {
runner
.chdir('./flags/gulpfile')
.gulp('--cwd ./cwd')
.run(cb);
function cb(err, stdout, stderr) {
stdout = headLines(stdout, 1, 3);
expect(stdout).toEqual(
'Another gulpfile : ' +
path.join(fixturesDir, 'flags/gulpfile/cwd/gulpfile.js')
);
expect(stderr).toEqual('');
done(err);
}
});
it('Should ignore a ./.gulp.* file if another gulpfile is specified by ' +
'\n\t--gulpfile', function(done) {
runner
.chdir('./flags/gulpfile')
.gulp('--gulpfile ./cwd/gulpfile.js')
.run(cb);
function cb(err, stdout, stderr) {
stdout = headLines(stdout, 1, 3);
expect(stdout).toEqual(
'Another gulpfile : ' +
path.join(fixturesDir, 'flags/gulpfile/cwd/gulpfile.js')
);
expect(stderr).toEqual('');
done(err);
}
});
});