gulp-sprite
gulp-sprite copied to clipboard
Doesn't seem to finish running the task if the src directory is empty
I have this set up in a "boilerplate" gulpfile for when I occasionally use sprite images. Occasionally being my keyword here, often times, I won't ever actually be using the sprite task.
However, I'd still like my watch task to watch the directory, just in case. But if the src directory doesn't have any images to turn into a sprite, it looks like it's not finishing and more or less killing the watch task, making it so my other tasks in watch never fire.
If there are images in the src directory, it generates fine and the rest of the watch tasks fire fine. It really just seems to be if there's nothing for the sprite task to do.
Hey Tyler, thanks for reporting. Can you please post your gulpfile so I can have a look into it. I tried with an empty src dir with a test gulpfile and it seems to work fine.
Huh, that's interesting. It might be something else then. Here's my gulpfile, (sorry for the lack of comments at the moment) if I run the gulp sprites task by itself (outside of the watch task), the notify message doesn't show up for me unless images are in the _src/sprites folder. That left me with the assumption that the empty directory was causing it to fail.
Thanks for taking a look.
Mh, i did npm install and then gulp init. After starting gulp sprite the output looks as follows:
git master* → gulp sprites
[gulp] Using file /Users/alexander/Development/tests/gulpproject/gulpfile.js
[gulp] Working directory changed to /Users/alexander/Development/tests/gulpproject
[gulp] Running 'sprites'...
[gulp] Finished 'sprites' in 68 ms
gulp watch seems also to work pretty much as supposed to.
By the way ... you could use node-bourbon and node-neat and then in your styles task do something like:
var bourbon = require('node-bourbon').includePaths;
var neat = require('node-neat').includePaths;
...
.pipe(sass({
includePaths: ['./src/scss'].concat(bourbon).concat(neat)
}))
So you don't need to init bourbon and neat in gulp init
Maybe there is a mismatch with the local and global gulp version?
git master* → gulp --version
[gulp] CLI version 3.5.2
[gulp] Local version 3.5.2
Huh, when you run just gulp sprite with an empty _src/sprites, do you get the "Sprites task completed" notification? If it isn't empty, I get the notification, but nothing otherwise. Maybe that's how gulp-notify intends, but it's what made me think the issue lied there.
The watch task works initially for me, but if I go in and save or add a file, it seems to stop. Says it's running, but it won't actually trigger the the tasks it seems. I'm not sure, this may be completely unrelated to gulp-sprite, but if I comment out my sprite task, it works continuously without issue.
I have both 3.5.2 CLI and local as well.
I'll keep playing around with it, see if I can get something more specific pinpointed. Thanks again for taking a look, and for the bourbon/neat tip, didn't know about that.
I did a bit more research and could find some things:
- gulp-notify only notifies if a file is present, so the behavior when the directory is empty is correct
- there was a bug in gulp-sprite which resulted in a segmentation fault when a new file was added while watching the directory (fixed with d29515c2fe39ad126e6fac407514492a36b196f8)
- when the directory is empty and a file is added nothing happens. This seems to be a problem with gulp.watch because I can reproduce the same behavior when I leave the scripts directory empty and add a new js file after starting
gulp watch