Skip to content

Commit 342889a

Browse files
committed
New: Allow an output file to be specified for --tasks-json flag (ref #24)
1 parent 3a8d7d3 commit 342889a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/shared/cliOptions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = {
5353
'Print a plaintext list of tasks for the loaded gulpfile.'),
5454
},
5555
'tasks-json': {
56-
type: 'boolean',
56+
type: 'string',
5757
desc: chalk.gray(
5858
'Print the task dependency tree, ' +
5959
'in JSON format, for the loaded gulpfile.'),

lib/versioned/^4.0.0-alpha.1/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
var fs = require('fs');
4+
35
var chalk = require('chalk');
46
var gutil = require('gulp-util');
57
var tildify = require('tildify');
@@ -35,9 +37,12 @@ function execute(opts, env) {
3537
});
3638
}
3739
if (opts.tasksJson) {
38-
return console.log(
39-
JSON.stringify(gulpInst.tree({ deep: true }), null, 2)
40-
);
40+
var output = JSON.stringify(gulpInst.tree({ deep: true }));
41+
if (typeof opts.tasksJson === 'boolean' && opts.tasksJson) {
42+
return console.log(output);
43+
} else {
44+
return fs.writeFileSync(opts.tasksJson, output, 'utf-8');
45+
}
4146
}
4247
try {
4348
gutil.log('Using gulpfile', chalk.magenta(tildify(env.configPath)));

0 commit comments

Comments
 (0)