selaux / node-sprite-generator

Generates image sprites and their spritesheets (css, stylus, sass or less) from sets of images. Supports retina sprites. Provides express middleware and grunt task.
MIT License
191 stars 39 forks source link

Make sure folders exist before writing files #45

Closed haydenbleasel closed 8 years ago

haydenbleasel commented 8 years ago

Handling this common I/O issue would be helpful for a lot of users, especially when we’re writing an image to a new folder.

haydenbleasel commented 8 years ago

Sorry about the multiple commits - my linter is wrecked at the moment and doesn't pick up on undefined variables or naming conflicts.

selaux commented 8 years ago

Sorry for the late response. Nice catch :+1:. It is true that something should be done about creating the directories that the files are written into. I'm not sure about the implementation though.

The easiest way I think this could be done is by adding a step in here that creates the directories, so that it isn't necessary to implement this for each stylesheet generator and compositor.

Let me know wether you want to adapt your PR or want me to take a look at this. If you want to create a PR, please add tests for the functionality.

haydenbleasel commented 8 years ago

@selaux Heya, I'm not sure how to write unit tests and the code changes are only small, so perhaps it would be more useful for you to adapt the PR. Sorry about that :/

selaux commented 8 years ago

No worries, thanks for the bug-report :+1: . I will close this in favor of https://github.com/selaux/node-sprite-generator/pull/46.