Extended COco COmpiler

It is assumed that you are familiar with coco language!

ecoco extends coco compiling features.

ecoco 0.2.4-1-beta

    ecoco [options] file [arguments]
    ecoco file -c [options]

    i.e. if you want to execute (not compile)
         then put arguments after file.


  --examples                 Show code examples

  --defaults                 Show default command line values

  --help, --usage, -h        Show help

  --version                  Show version

  --ckup                     Compile ckup file into `.js` file. Output file
                             will have `//uuid:X` at the beginning, where X is
                             UUID v1. JavaScript in output file will be

  --compile, -c              Equivalent to `coco -c`

  --bare, -b                 Equivalent to `coco -b`

  --uglify, -u, --compress   Compress output (uses `uglify-js`)

  --binary                   Output filename without `.js` and adds
                             `#!/usr/bin/env node` at the beginning of output

  --include FILE             If FILE has `co` extension then AT COMPILE TIME
                             prepend FILE to source file. Otherwise if FILE has
                             `js` extension then AFTER compiling prepend FILE
                             to compiled file.

  --make-readme FILE         Replace `{CLI}` in `` with `file
                             --usage` and save it to ``.

  --no-colors                Disable color output

  --no-beep                  Disable error beep


  ecoco -cbu     compiles to awesome.js with `bare` and `uglify`
  ecoco --ckup index.ckup   compiles `index.ckup` into `index.js`
  ecoco --make-readme       compiles into
  ecoco --what    executes with `--what` argument

Adding these at the beggining of your source file will change Ecoco behaviour accordingly:

  • #!b or #!bare like ecoco -b
  • #!u or #!ugly or #!uglify like ecoco -u
  • #!binary like ecoco --binary
  • #!include=filename or #! like ecoco --include
  • #!replace pattern, replacement (coco style regexp replace function)

Ecoco.json has similar functionality as Apaches' .htaccess. You put this file in the same folder as your .co script or in one of the parent folders (up to file system root). At the moment in Ecoco.json you can define two options: headers (array), and project_info (string).


        "replace /^([\t]*)log (.*)$/gm, \"$1log $2, module.filename\"",
    "project_info": "project info"

Following lines will be added to script just before compilation:

#!replace /^([\t]*)log (.*)$/gm, "$1log $2, module.filename"

And project info will be added in the .js file in top comment section.

fn = -> "ok!"

compiles to

  var fn;
  fn = function(){
    return "ok!";



fn = -> "bare!"

compiles to

var fn;
fn = function(){
  return "bare!";



fn = -> "uglify!"

compiles to

(function(){var e;e=function(){return"uglify!"}}).call(this)


process.stdout.write "I'm alive!\n"

compiles to node_bin:

#!/usr/bin/env node
  process.stdout.write("I'm alive!\n");


im_not_alone = true

you_are_not_alone = true

ecoco compiles to:

  var you_are_not_alone, im_not_alone;
  you_are_not_alone = true;
  im_not_alone = true;

npm install -g ecoco


git clone && cd ecoco && npm install && npm link

or if you want to build

git clone && cd ecoco && npm install && coco && npm link

  • 0.2.4-beta

  • Added support for .ckup files (See this)

  • 0.2.3-beta

  • Added ecoco.json support.

  • Ecoco will add top comment section into output .js file with some info.