grunt2gulp.js: JavaScript to CoffeeScript?

grunt2gulp-logoSo I don’t know if anyone is actively following the development of grunt2gulp.js but I decided to be a little more active in working on it. A week ago at work someone mentioned CoffeeScript and it’s a good time to check it out. I initially used it a long time ago when it first became available and I liked the result but it didn’t offer a huge improvement on the little JavaScript that we were writing at the time (under 200 lines of code).

However, grunt2gulp.js is starting to get…hairy. It’s about 400 lines (or more?) now and it’s time to split things up into separate files at the least.

I created a new branch called zesty-coffee and it’ll be using CoffeeScript. I’m using the npm preinstall script to compile the files into the bin/ script. Next step is making sure the conversion is complete and works correctly and after that I’m going to create a Gruntfile.js for linting the generated grunt2gulp.js file and for generating the JSDocs from it. After that we’ll have a good working example of a Gruntfile that can be converted to gulp within the repo so it’s easier to dog-food grunt2gulp.

The generated JavaScript from CoffeeScript is very nice and readable so debugging isn’t a chore. The list comprehensions in CoffeeScript do encourage a slightly different coding style and the lighter syntax for creating anonymous functions (a.k.a. blocks a.k.a. lambdas) encourages an almost functional style.

Check out the zesty-coffee branch on github.

Check out grunt2gulp on NPM.

Check out grunt2gulp on GitHub.

UPDATE: I manually converted the code from JavaScript to CoffeeScript. If you’re looking to automate your conversion from javascript to coffee, you can check out js2coffee.