1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00
jashkenas--coffeescript/Rakefile

42 lines
1.1 KiB
Text
Raw Normal View History

2009-12-18 09:55:31 -05:00
require 'erb'
2009-12-18 06:59:06 -05:00
require 'fileutils'
require 'rake/testtask'
require 'rubygems'
require 'yui/compressor'
2009-12-18 06:59:06 -05:00
HEADER = <<-EOS
/**
* CoffeeScript Compiler v0.7.2
* http://coffeescript.org
*
* Copyright 2010, Jeremy Ashkenas
* Released under the MIT License
*/
EOS
2009-12-18 09:55:31 -05:00
desc "Build the documentation page"
task :doc do
source = 'documentation/index.html.erb'
2010-07-29 00:51:35 -04:00
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
2009-12-18 09:55:31 -05:00
end
desc "Build the single concatenated and minified script for the browser"
task :browser do
sources = %w(helpers.js rewriter.js lexer.js parser.js scope.js nodes.js coffee-script.js)
code = sources.map {|s| File.read('lib/' + s) }.join('')
code = YUI::JavaScriptCompressor.new.compress(code)
File.open('extras/coffee-script.js', 'w+') {|f| f.write(HEADER + code) }
end