How to run a function during a Gulp execution so that Gulp treats the function as a task (prints it to the log)?
Here is an example of my gulpfile.js:
async function doStaff(todo) {
// ...
}
exports.default = async () => {
// Some asynchronous logic which gets the subtasks
const todos = await myAPI.getTodos();
await Promise.all(todos.map(async todo => {
const subTask = doStuff.bind(todo);
subTask.displayName = `todo «${todo.name}»`;
await subTask(); // I want it to run as a Gulp task
}));
};
Expected Gulp output:
Starting 'default'...
Starting 'todo «foo»'...
Starting 'todo «bar»'...
Finished 'todo «foo»' after 1.2s
Finished 'todo «bar»' after 1.5s
Finished 'default' after 2s
Actual Gulp output:
Starting 'default'...
Finished 'default' after 2s
Why: My list of subtasks can't be retrieved synchronously and Gulp doesn't support asynchronous configuration and isn't going to support it. Never the less I want to see the subtasks progress and timing in the Gulp output.