-
-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathflags-gulpfile.js
70 lines (55 loc) · 2.05 KB
/
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
'use strict';
var expect = require('expect');
var exec = require('child_process').exec;
var path = require('path');
var sliceLines = require('./tool/slice-lines');
var gulp = require('./tool/gulp-cmd');
var baseDir = path.join(__dirname, '..');
describe('flag: --gulpfile', function() {
it('Manually set path of gulpfile using --gulpfile', function(done) {
var gulpfilePath = 'test/fixtures/gulpfiles/gulpfile-2.js';
var opts = { cwd: baseDir };
exec(gulp('--gulpfile', gulpfilePath), opts, cb);
function cb(err, stdout, stderr) {
expect(err).toBeNull();
expect(stderr).toEqual('');
var chgWorkdirLog = sliceLines(stdout, 0, 1);
var workdir = path.dirname(gulpfilePath).replace(/\//g, path.sep);
expect(chgWorkdirLog).toMatch('Working directory changed to ');
expect(chgWorkdirLog).toMatch(workdir);
stdout = sliceLines(stdout, 2);
expect(stdout).toEqual(
'Starting \'default\'...\n' +
'Starting \'logGulpfilePath\'...\n' +
path.resolve(gulpfilePath) + '\n' +
'Finished \'logGulpfilePath\' after ?\n' +
'Finished \'default\' after ?\n' +
''
);
done(err);
}
});
it('Manually set path of gulpfile using -f', function(done) {
var gulpfilePath = 'test/fixtures/gulpfiles/gulpfile-2.js';
var opts = { cwd: baseDir };
exec(gulp('-f', gulpfilePath), opts, cb);
function cb(err, stdout, stderr) {
expect(err).toBeNull();
expect(stderr).toEqual('');
var chgWorkdirLog = sliceLines(stdout, 0, 1);
var workdir = path.dirname(gulpfilePath).replace(/\//g, path.sep);
expect(chgWorkdirLog).toMatch('Working directory changed to ');
expect(chgWorkdirLog).toMatch(workdir);
stdout = sliceLines(stdout, 2);
expect(stdout).toEqual(
'Starting \'default\'...\n' +
'Starting \'logGulpfilePath\'...\n' +
path.resolve(gulpfilePath) + '\n' +
'Finished \'logGulpfilePath\' after ?\n' +
'Finished \'default\' after ?\n' +
''
);
done(err);
}
});
});