Skip to content

Commit a6a1e34

Browse files
erikkempermanphated
authored andcommitted
New: Add -f alias for --gulpfile flag (#121)
1 parent 3828d1d commit a6a1e34

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ __Some flags only work with gulp 4 and will be ignored when invoked against gulp
144144
</tr>
145145
<tr>
146146
<td>--gulpfile [path]</td>
147-
<td></td>
147+
<td>-f</td>
148148
<td>Manually set path of gulpfile. Useful if you have multiple gulpfiles. This will set the CWD to the gulpfile directory as well.</td>
149149
</tr>
150150
<tr>

lib/shared/cliOptions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module.exports = {
2323
'This is useful for transpilers but also has other applications.'),
2424
},
2525
gulpfile: {
26+
alias: 'f',
2627
type: 'string',
2728
requiresArg: true,
2829
desc: chalk.gray(

test/expected/flags-help.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Options:
55
--help, -h Show this help. [boolean]
66
--version, -v Print the global and local gulp versions. [boolean]
77
--require Will require a module before running the gulpfile. This is useful for transpilers but also has other applications. [string]
8-
--gulpfile Manually set path of gulpfile. Useful if you have multiple gulpfiles. This will set the CWD to the gulpfile directory as well. [string]
8+
--gulpfile, -f Manually set path of gulpfile. Useful if you have multiple gulpfiles. This will set the CWD to the gulpfile directory as well. [string]
99
--cwd Manually set the CWD. The search for the gulpfile, as well as the relativity of all requires will be from here. [string]
1010
--verify Will verify plugins referenced in project's package.json against the plugins blacklist.
1111
--tasks, -T Print the task dependency tree for the loaded gulpfile. [boolean]

test/flags-gulpfile.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var path = require('path');
1010

1111
describe('flag: --gulpfile', function() {
1212

13-
it('Manually set path of gulpfile', function(done) {
13+
it('Manually set path of gulpfile using --gulpfile', function(done) {
1414
var gulpfilePath = 'test/fixtures/gulpfiles/gulpfile-2.js';
1515

1616
runner({ verbose: false })
@@ -39,4 +39,33 @@ describe('flag: --gulpfile', function() {
3939
}
4040
});
4141

42+
it('Manually set path of gulpfile using -f', function(done) {
43+
var gulpfilePath = 'test/fixtures/gulpfiles/gulpfile-2.js';
44+
45+
runner({ verbose: false })
46+
.gulp('-f', gulpfilePath)
47+
.run(cb);
48+
49+
function cb(err, stdout, stderr) {
50+
expect(err).toEqual(null);
51+
expect(stderr).toEqual('');
52+
53+
var chgWorkdirLog = headLines(stdout, 1);
54+
var workdir = path.dirname(gulpfilePath).replace(/\//g, path.sep);
55+
expect(chgWorkdirLog).toMatch('Working directory changed to ');
56+
expect(chgWorkdirLog).toMatch(workdir);
57+
58+
stdout = eraseLapse(eraseTime(skipLines(stdout, 2)));
59+
expect(stdout).toEqual(
60+
'Starting \'default\'...\n' +
61+
'Starting \'logGulpfilePath\'...\n' +
62+
path.resolve(gulpfilePath) + '\n' +
63+
'Finished \'logGulpfilePath\' after ?\n' +
64+
'Finished \'default\' after ?\n' +
65+
''
66+
);
67+
done(err);
68+
}
69+
});
70+
4271
});

0 commit comments

Comments
 (0)