-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update: Support new alpha of gulp 4 to handle new undertaker tree ret…
…urn value
- Loading branch information
Showing
8 changed files
with
90 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
'use strict'; | ||
|
||
var fs = require('fs'); | ||
|
||
var log = require('gulplog'); | ||
var chalk = require('chalk'); | ||
var stdout = require('mute-stdout'); | ||
var tildify = require('tildify'); | ||
|
||
var exit = require('../../shared/exit'); | ||
|
||
var logTasks = require('../../shared/log/tasks'); | ||
var logEvents = require('./log/events'); | ||
var logSyncTask = require('./log/syncTask'); | ||
var logTasksSimple = require('./log/tasksSimple'); | ||
|
||
function execute(opts, env) { | ||
|
||
var tasks = opts._; | ||
var toRun = tasks.length ? tasks : ['default']; | ||
|
||
if (opts.tasksSimple || opts.tasks || opts.tasksJson) { | ||
// Mute stdout if we are listing tasks | ||
stdout.mute(); | ||
} | ||
|
||
var gulpInst = require(env.modulePath); | ||
logEvents(gulpInst); | ||
logSyncTask(gulpInst); | ||
|
||
// This is what actually loads up the gulpfile | ||
require(env.configPath); | ||
|
||
// Always unmute stdout after gulpfile is required | ||
stdout.unmute(); | ||
|
||
process.nextTick(function() { | ||
var tree; | ||
|
||
if (opts.tasksSimple) { | ||
tree = gulpInst.tree(); | ||
return logTasksSimple(tree.nodes); | ||
} | ||
if (opts.tasks) { | ||
tree = gulpInst.tree({ deep: true }); | ||
tree.label = 'Tasks for ' + chalk.magenta(tildify(env.configPath)); | ||
|
||
return logTasks(tree, function(task) { | ||
return gulpInst.task(task).description; | ||
}); | ||
} | ||
if (opts.tasksJson) { | ||
tree = gulpInst.tree({ deep: true }); | ||
tree.label = 'Tasks for ' + tildify(env.configPath); | ||
|
||
var output = JSON.stringify(tree); | ||
|
||
if (typeof opts.tasksJson === 'boolean' && opts.tasksJson) { | ||
return console.log(output); | ||
} else { | ||
return fs.writeFileSync(opts.tasksJson, output, 'utf-8'); | ||
} | ||
} | ||
try { | ||
log.info('Using gulpfile', chalk.magenta(tildify(env.configPath))); | ||
gulpInst.parallel(toRun)(function(err) { | ||
if (err) { | ||
exit(1); | ||
} | ||
}); | ||
} catch (err) { | ||
log.error(chalk.red(err.message)); | ||
log.error('To list available tasks, try running: gulp --tasks'); | ||
exit(1); | ||
} | ||
}); | ||
} | ||
|
||
module.exports = execute; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[{"label":"test1","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test2","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"test1","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test3","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"described","type":"function","nodes":[]}]}]},{"label":"test4","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"errorFunction","type":"function","nodes":[]},{"label":"anon","type":"function","nodes":[]}]}]},{"label":"default","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"test1","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test3","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"described","type":"function","nodes":[]}]}]},{"label":"noop","type":"function","nodes":[]}]}]}] | ||
{"label":"Tasks for {{path}}","nodes":[{"label":"test1","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test2","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"test1","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test3","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"described","type":"function","nodes":[]}]}]},{"label":"test4","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"errorFunction","type":"function","nodes":[]},{"label":"anon","type":"function","nodes":[]}]}]},{"label":"default","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"test1","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"noop","type":"function","nodes":[]}]}]},{"label":"test3","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"described","type":"function","nodes":[]}]}]},{"label":"noop","type":"function","nodes":[]}]}]}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters