You can install this package via
npm install coffeescript-compiler. Please note that this package does NOT define any version of
coffee-script as a dependency for any reason other than testing. You must either have the
coffee command available in your path or have the complete path to access the
All examples assume that you have included this module and created a new
Compiler as follows:
var Compiler = require('coffeescript-compiler'); var cc = new Compiler();
Assuming you have
coffee on your path, compiling a string of CoffeeScript (in this example,
a = 5) is simple:
You can get a bare compilation (no wrapper function) by passing in a configuration object as the second argument to
The configuration object can contain the following options:
asFileName: If set to
truethe first argument passed to
compileis treated as a file name rather than an input string. If this is set and an error is encountered while reading the error will be thrown.
The MIT License
Copyright (c) 2012 Kenneth Powers
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.