Convert yours JavaScript to CoffeeScript, vice versa, just for ruby developer.
Philosophy
- Keep it simple, a command line with no more options.
- Pretty format output with coderay.
- Watch a directory, convert automaticly when file change.
- SourceMap generation automaticly, for debug with CoffeeScript in Firefox/Chrome.
- With Nodejs, just for Ruby on Rails developer.
Getting Started
Install via Rubygems
$ gem install js2coffee
Usage
Run js2coffee
or js2coffee
individually. (old command coff
is not available.)
Compile script file to STDOUT.
$ coffee2js your_awesome.coffee
You can redirect STDOUT to a new file.
$ coffee2js your_awesome.coffee > you_awesome.js
Watching one directory
$ coffee2js script_directory
This will create corresponding js(.js) and Source Map(.js.map) in same directory as coffee file live in.
map file will keep hide with leading dot, e.g. awesome.js
will create awesome.coffee and .awesome.js.map
If one directory named coffee
or named js
in you project root, will create another directory
automaticly with cloned directory hierarchy, this will make js and coffee file saved seperately.
Compile script directly
You can run coffee script directly with: -e
argments or pipe.
Environment variable
You can setting JS2COFFEE_EXCLUDE_PATTERN
to specify the pattern to be skipped when watching one directory.
$ export JS2COFFEE_EXCLUDE_PATTERN='one_pattern|another_pattern'
js2coffee will always skip node_modules
and bower_components
.
Support
- MRI 1.9.3+
- Rubinius 2.2+
Compiler current used:
- CoffeeScript 1.1.0, used for convert from CoffeeScript to JavaScript.
- js2coffee 2.1.0, used for convert JavaScript to CoffeeScript.
History
More update info, please See CHANGELOG for details.
Contributing
- Bug reports
- Source
- Patches:
- Fork on Github.
- Run
gem install --dev js2coffee
orbundle
. - Create your feature branch:
git checkout -b my-new-feature
. - Commit your changes:
git commit -am 'Add some feature'
. - Push to the branch:
git push origin my-new-feature
. - Send a pull request :D.
license
Released under the MIT license, See LICENSE for details.