Skip to content

Commit

Permalink
New: Support exporting tasks from a gulpfile
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Dec 21, 2017
1 parent 0b8e1c1 commit 51ca1fc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/versioned/^4.0.0-alpha.1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var logTasks = require('../../shared/log/tasks');
var logEvents = require('../^4.0.0/log/events');
var logSyncTask = require('../^4.0.0/log/syncTask');
var logTasksSimple = require('../^4.0.0/log/tasksSimple');
var registerExports = require('../^4.0.0/register-exports');

function execute(opts, env) {

Expand All @@ -29,7 +30,9 @@ function execute(opts, env) {
logSyncTask(gulpInst);

// This is what actually loads up the gulpfile
require(env.configPath);
var exported = require(env.configPath);

registerExports(gulpInst, exported);

// Always unmute stdout after gulpfile is required
stdout.unmute();
Expand Down
5 changes: 4 additions & 1 deletion lib/versioned/^4.0.0-alpha.2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var logTasks = require('../../shared/log/tasks');
var logEvents = require('../^4.0.0/log/events');
var logSyncTask = require('../^4.0.0/log/syncTask');
var logTasksSimple = require('../^4.0.0/log/tasksSimple');
var registerExports = require('../^4.0.0/register-exports');

function execute(opts, env) {

Expand All @@ -29,7 +30,9 @@ function execute(opts, env) {
logSyncTask(gulpInst);

// This is what actually loads up the gulpfile
require(env.configPath);
var exported = require(env.configPath);

registerExports(gulpInst, exported);

// Always unmute stdout after gulpfile is required
stdout.unmute();
Expand Down
5 changes: 4 additions & 1 deletion lib/versioned/^4.0.0/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var logTasks = require('../../shared/log/tasks');
var logEvents = require('./log/events');
var logSyncTask = require('./log/syncTask');
var logTasksSimple = require('./log/tasksSimple');
var registerExports = require('./register-exports');

function execute(opts, env) {

Expand All @@ -29,7 +30,9 @@ function execute(opts, env) {
logSyncTask(gulpInst);

// This is what actually loads up the gulpfile
require(env.configPath);
var exported = require(env.configPath);

registerExports(gulpInst, exported);

// Always unmute stdout after gulpfile is required
stdout.unmute();
Expand Down
21 changes: 21 additions & 0 deletions lib/versioned/^4.0.0/register-exports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

function registerExports(gulpInst, tasks) {
var taskNames = Object.keys(tasks);

if (taskNames.length) {
taskNames.forEach(register);
}

function register(taskName) {
var task = tasks[taskName];

if (typeof task !== 'function') {
return;
}

gulpInst.task(taskName, task);
}
}

module.exports = registerExports;

0 comments on commit 51ca1fc

Please sign in to comment.