0

Looking for a way to produce an express scaffold in coffeescript straight off the bat.

At the moment $ express 'myapp' just creates js files.

Any pointers will be appreciated. Thanks.

Clive
  • 3,991
  • 3
  • 17
  • 15

3 Answers3

2

You can transform the created app.js and routes/index.js files into coffeescript using js2coffee (like Slace stated)
There are two ways:
1. Manually using the js2coffee.org converter
2. Using the js2coffee npm package and piping the output into a new file

$ cd my_new_express_app
$ sudo npm install js2coffee -g
Files can now be converted by running js2coffee input.js > output.coffee 
$ js2coffee app.js > app.coffee
$ js2coffee routes/index.js > routes/index.coffee

This way you can start a fresh express project in coffeescript. Note that the conversion strips comments away.

1

Express only generates JavaScript from the scaffolding. You can use js2coffee to do the conversion yourself.

Aaron Powell
  • 24,927
  • 18
  • 98
  • 150
0

After generating your express app and installing js2coffee, as previously mentioned, change directory to your new app and run:

for f in `find . -type f -path "*.js" ! -path "*node_modules*"`; js2coffee $f > "${f%.*}.coffee"
Tim Santeford
  • 27,385
  • 16
  • 74
  • 101