Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running task steps per folder fails if containing folder is empty. #2122

Comments

@dave-cross
Copy link

I set up a similar task to the one described here: https://github.com/gulpjs/gulp/blob/master/docs/recipes/running-task-steps-per-folder.md

Instead of running JS or SCSS, it runs a sprite generator.

The issue is that if there're no folders returned from getFolders(), the task (and any sequenced/parallel tasks), fail. Without subfolders in the src path, .map won't run... which means gulp scripts don't fire... leaving us with a null stream.

Is there any way to return an "empty" stream if no folders are present or inform gulp that the task has run successfully in the same instance?

@yocontra
Copy link
Member

yocontra commented Feb 9, 2018

I think it would be pretty obvious that you should put something in the folder you're processing, but I added a check for it in the example code in the commit above. You can just return if there are no folders to merge.

@phated
Copy link
Member

phated commented Feb 9, 2018

@contra thats not correct and you didn't follow the conventional changelog style

@phated phated reopened this Feb 9, 2018
@yocontra
Copy link
Member

yocontra commented Feb 9, 2018

@phated What isn't correct about it? Did the way synchronous functions work change in undertaker?

@phated
Copy link
Member

phated commented Feb 9, 2018

Sync functions are not supported. That's been in forever.

@dave-cross
Copy link
Author

@contra, That conditional didn't work. I still get errors that the task didn't complete. As for 'putting something in the folder I'm processing", I did mention that it's a sprite generator. It is possible SVGs haven't been made and added yet.

Thank you both for answering.

@yocontra
Copy link
Member

yocontra commented Feb 10, 2018

@cloudsociety Replace the return with return done() and add a done arg to your task function. Published a fix for it - I forgot master = 4.0 docs now, not the 3.x stuff. If you're using 3.x the return will work fine.

@phated
Copy link
Member

phated commented Feb 11, 2018

I've rebased and cleaned up the result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment