I am trying to automate file creation in gulp. I made a prepare task that should take section names from an array and generate files with built-in markup inside:
function prepare(){
for(let i = 0; i==sections.length-1;i++){
return createFile(`src/parts/_${sections[i]}.html`, `
<div class="${sections[i]}">
<div class="${sections[i]}__content ${sections[i]}__container"></div>
</div>\n`,
function (err) {
// file either already exists or is now created (including non existing directories)
});
}
}
But this error comes out: enter image description here
It means the lack of return in the function. How to execute a for loop creating files and still use return?