diff --git a/lib/shared/cliOptions.js b/lib/shared/cliOptions.js index e6ed0dda..e77a8f19 100644 --- a/lib/shared/cliOptions.js +++ b/lib/shared/cliOptions.js @@ -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.'), diff --git a/lib/versioned/^4.0.0-alpha.1/index.js b/lib/versioned/^4.0.0-alpha.1/index.js index 4f949216..71ef9467 100644 --- a/lib/versioned/^4.0.0-alpha.1/index.js +++ b/lib/versioned/^4.0.0-alpha.1/index.js @@ -1,5 +1,7 @@ 'use strict'; +var fs = require('fs'); + var chalk = require('chalk'); var gutil = require('gulp-util'); var tildify = require('tildify'); @@ -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)));