Skip to content

Commit

Permalink
New: Add -f alias for --gulpfile flag (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkemperman authored and phated committed Dec 21, 2017
1 parent 3828d1d commit a6a1e34
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ __Some flags only work with gulp 4 and will be ignored when invoked against gulp
</tr>
<tr>
<td>--gulpfile [path]</td>
<td></td>
<td>-f</td>
<td>Manually set path of gulpfile. Useful if you have multiple gulpfiles. This will set the CWD to the gulpfile directory as well.</td>
</tr>
<tr>
Expand Down
1 change: 1 addition & 0 deletions lib/shared/cliOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = {
'This is useful for transpilers but also has other applications.'),
},
gulpfile: {
alias: 'f',
type: 'string',
requiresArg: true,
desc: chalk.gray(
Expand Down
2 changes: 1 addition & 1 deletion test/expected/flags-help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Options:
--help, -h Show this help. [boolean]
--version, -v Print the global and local gulp versions. [boolean]
--require Will require a module before running the gulpfile. This is useful for transpilers but also has other applications. [string]
--gulpfile Manually set path of gulpfile. Useful if you have multiple gulpfiles. This will set the CWD to the gulpfile directory as well. [string]
--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]
--cwd Manually set the CWD. The search for the gulpfile, as well as the relativity of all requires will be from here. [string]
--verify Will verify plugins referenced in project's package.json against the plugins blacklist.
--tasks, -T Print the task dependency tree for the loaded gulpfile. [boolean]
Expand Down
31 changes: 30 additions & 1 deletion test/flags-gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var path = require('path');

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

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

runner({ verbose: false })
Expand Down Expand Up @@ -39,4 +39,33 @@ describe('flag: --gulpfile', function() {
}
});

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

runner({ verbose: false })
.gulp('-f', gulpfilePath)
.run(cb);

function cb(err, stdout, stderr) {
expect(err).toEqual(null);
expect(stderr).toEqual('');

var chgWorkdirLog = headLines(stdout, 1);
var workdir = path.dirname(gulpfilePath).replace(/\//g, path.sep);
expect(chgWorkdirLog).toMatch('Working directory changed to ');
expect(chgWorkdirLog).toMatch(workdir);

stdout = eraseLapse(eraseTime(skipLines(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);
}
});

});

0 comments on commit a6a1e34

Please sign in to comment.