-
Hi everyone, I'm having this weird issue, its probably due to me not understanding how to really use it, but I'm not making any progress by reading documentations.
This means it's generating new tasks on the fly (e.g. when a new template gets added), but I'm always having issues with async completion. const {
src,
dest,
series
} = require('gulp');
const {
setTimeout
} = require('timers/promises')
const env = ['1', '2', '3'];
const template = ['1', '2', '3'];
function renderEnv(info) {
console.debug('renderEnv', info);
const funcs = template.map(n => mod(renderTemplate, n));
return series(...funcs);
}
function renderTemplate(info) {
console.debug('renderTemplate', info);
}
// this mods params to bind with correct args while keeping the name
function mod(func, args, name) {
const argArray = Array.isArray(args) ? args : [args];
const newFunc = func.bind(null, ...argArray);
newFunc.displayName = name || func.name;
return newFunc;
}
function defaultFunc() {
const funcs = env.map(n => mod(renderEnv, n));
return series(...funcs)
}
exports.default = series(defaultFunc()); here is the error:
Whatever I tweak and adjust, I always get this error (even when renderTemplate returns a promise, but looking at the logs it never even gets called...?) Can anyone point me in the right direction? what am I doing wrong. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
While digging through some other GitHub issues, I finally understood that gulp doesn't expect a task to return another series (aka a function). function renderEnv(info, done) {
console.debug('renderEnv', info);
const funcs = template.map(n => mod(renderTemplate, n));
return series(...funcs)(done); // (or parallel)
} this will work like I wanted it and the execution log also follows my expected graph. |
Beta Was this translation helpful? Give feedback.
While digging through some other GitHub issues, I finally understood that gulp doesn't expect a task to return another series (aka a function).
So I have to replace renderEnv with this:
this will work like I wanted it and the execution log also follows my expected graph.