Skip to content

Commit

Permalink
New: Allow an output file to be specified for --tasks-json flag (ref #24
Browse files Browse the repository at this point in the history
)
  • Loading branch information
phated committed Dec 21, 2017
1 parent 3a8d7d3 commit 342889a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/shared/cliOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = {
'Print a plaintext list of tasks for the loaded gulpfile.'),
},
'tasks-json': {
type: 'boolean',
type: 'string',
desc: chalk.gray(
'Print the task dependency tree, ' +
'in JSON format, for the loaded gulpfile.'),
Expand Down
11 changes: 8 additions & 3 deletions lib/versioned/^4.0.0-alpha.1/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

var fs = require('fs');

var chalk = require('chalk');
var gutil = require('gulp-util');
var tildify = require('tildify');
Expand Down Expand Up @@ -35,9 +37,12 @@ function execute(opts, env) {
});
}
if (opts.tasksJson) {
return console.log(
JSON.stringify(gulpInst.tree({ deep: true }), null, 2)
);
var output = JSON.stringify(gulpInst.tree({ deep: true }));
if (typeof opts.tasksJson === 'boolean' && opts.tasksJson) {
return console.log(output);
} else {
return fs.writeFileSync(opts.tasksJson, output, 'utf-8');
}
}
try {
gutil.log('Using gulpfile', chalk.magenta(tildify(env.configPath)));
Expand Down

0 comments on commit 342889a

Please sign in to comment.