Skip to content

Commit 51ca1fc

Browse files
committed
New: Support exporting tasks from a gulpfile
1 parent 0b8e1c1 commit 51ca1fc

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var logTasks = require('../../shared/log/tasks');
1313
var logEvents = require('../^4.0.0/log/events');
1414
var logSyncTask = require('../^4.0.0/log/syncTask');
1515
var logTasksSimple = require('../^4.0.0/log/tasksSimple');
16+
var registerExports = require('../^4.0.0/register-exports');
1617

1718
function execute(opts, env) {
1819

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

3132
// This is what actually loads up the gulpfile
32-
require(env.configPath);
33+
var exported = require(env.configPath);
34+
35+
registerExports(gulpInst, exported);
3336

3437
// Always unmute stdout after gulpfile is required
3538
stdout.unmute();

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var logTasks = require('../../shared/log/tasks');
1313
var logEvents = require('../^4.0.0/log/events');
1414
var logSyncTask = require('../^4.0.0/log/syncTask');
1515
var logTasksSimple = require('../^4.0.0/log/tasksSimple');
16+
var registerExports = require('../^4.0.0/register-exports');
1617

1718
function execute(opts, env) {
1819

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

3132
// This is what actually loads up the gulpfile
32-
require(env.configPath);
33+
var exported = require(env.configPath);
34+
35+
registerExports(gulpInst, exported);
3336

3437
// Always unmute stdout after gulpfile is required
3538
stdout.unmute();

lib/versioned/^4.0.0/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var logTasks = require('../../shared/log/tasks');
1313
var logEvents = require('./log/events');
1414
var logSyncTask = require('./log/syncTask');
1515
var logTasksSimple = require('./log/tasksSimple');
16+
var registerExports = require('./register-exports');
1617

1718
function execute(opts, env) {
1819

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

3132
// This is what actually loads up the gulpfile
32-
require(env.configPath);
33+
var exported = require(env.configPath);
34+
35+
registerExports(gulpInst, exported);
3336

3437
// Always unmute stdout after gulpfile is required
3538
stdout.unmute();
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
function registerExports(gulpInst, tasks) {
4+
var taskNames = Object.keys(tasks);
5+
6+
if (taskNames.length) {
7+
taskNames.forEach(register);
8+
}
9+
10+
function register(taskName) {
11+
var task = tasks[taskName];
12+
13+
if (typeof task !== 'function') {
14+
return;
15+
}
16+
17+
gulpInst.task(taskName, task);
18+
}
19+
}
20+
21+
module.exports = registerExports;

0 commit comments

Comments
 (0)