Read my book

I wrote books about Webpack and React. Check them out!

Monday, September 2, 2013

Transformation Utilities - ioscript.js and png2ico

ioscript.js was one of the first Node.js libraries I released to the public. That was over year ago. Today I had the perfect excuse to revisit the library.

The basic idea of the library is very simple. It provides a shell for a cli script. In case the provided input is a directory, it traverses it recursively, executes the given callback on it and the outputs to a directory it as defined by the user. My recent changes made the library more versatile and fitting for more complex cases.

png2ico was such a case. I wanted an utility that could transform pngs in a given directory to a set of icos. In addition it was important for me to pick only certain png files. That is why I implemented a regex based filtering system that may be inverted. The syntax might be familiar to you from grep.

I know some people say you shouldn't write cli utilities using Node.js. Personally I rather deal with Node.js than Bash, Python or Perl. Your mileage might vary of course. In my case ioscript.js takes care of the boring stuff and allows me to focus on the hard part, the transformation.

I hope you enjoy these little utilities! If you have ideas how to improve them further, let me know in the comments.

I also published Monthly JSter today. So if you are looking for a set of interesting JavaScript related links to go through, check that out. Besides blog we provide Monthly JSter in an easy to consume mailing list in which you might want to subscribe. It is nowhere near as popular as JavaScript Weekly but I try to make up for it in quality. :)