Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 53 lines (50 sloc) 1.428 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
require 'erb'
require 'fileutils'
require 'rake/testtask'
require 'rubygems'
require 'closure-compiler'

HEADER = <<-EOS
/**
* CoffeeScript Compiler v0.9.4
* http://coffeescript.org
*
* Copyright 2010, Jeremy Ashkenas
* Released under the MIT License
*/
EOS

desc "Build the documentation page"
task :doc do
  source = 'documentation/index.html.erb'
  child = fork { exec "bin/coffee --no-wrap -cw -o documentation/js documentation/coffee/*.coffee" }
  at_exit { Process.kill("INT", child) }
  Signal.trap("INT") { exit }
  loop do
    mtime = File.stat(source).mtime
    if !@mtime || mtime > @mtime
      rendered = ERB.new(File.read(source)).result(binding)
      File.open('index.html', 'w+') {|f| f.write(rendered) }
    end
    @mtime = mtime
    sleep 1
  end
end

desc "Build the single concatenated and minified script for the browser"
task :browser do
  sources = %w(helpers rewriter lexer parser scope nodes coffee-script browser)
  code = sources.inject '' do |js, name|
    js << <<-"JS"
require['./#{name}'] = new function(){
var exports = this;
#{ File.read "lib/#{name}.js" }
}
JS
  end
  code = Closure::Compiler.new.compress(<<-"JS")
this.CoffeeScript = function(){
function require(path){ return require[path] }
#{ code }
return require['./coffee-script']
}()
JS
  File.open('extras/coffee-script.js', 'wb+') {|f| f.write(HEADER + code) }
end
Something went wrong with that request. Please try again.