From 448ed36cd2ee93efd7844278142e4d6cb95a8dfe Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Tue, 16 Feb 2010 19:17:57 -0500 Subject: [PATCH] got a build script for rebuilding the compiler, too --- build.coffee | 12 ++++++++++++ lib/coffee_script/command_line.js | 2 +- src/command_line.coffee | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/build.coffee b/build.coffee index 98b6067c..fe390b3c 100755 --- a/build.coffee +++ b/build.coffee @@ -4,10 +4,22 @@ fs: require 'fs' +# Run a CoffeeScript through our node/coffee interpreter. +run: (args) -> + proc: process.createChildProcess 'bin/node_coffee', args + proc.addListener 'error', (err) -> if err then puts err + # Print the usage message for the build scripts. usage: -> puts "build.coffee usage goes here..." +# Build the CoffeeScript source code -- if you're editing the parser, run +# this before you run "build parser". +build_compiler: -> + fs.readdir('src').addCallback (files) -> + files: 'src/' + file for file in files when file.match(/\.coffee$/) + run ['-o', 'lib/coffee_script'].concat(files) + # Rebuild the Jison parser from the compiled lib/grammar.js file. build_parser: -> parser: require('grammar').parser diff --git a/lib/coffee_script/command_line.js b/lib/coffee_script/command_line.js index d39a2609..d17aa19a 100644 --- a/lib/coffee_script/command_line.js +++ b/lib/coffee_script/command_line.js @@ -83,7 +83,7 @@ } else { js = coffee.compile(code); if (opts.run) { - process.compile(js, source); + eval(js); } else if (opts.print) { puts(js); } else if (opts.lint) { diff --git a/src/command_line.coffee b/src/command_line.coffee index 945afe4f..2c7ac7ff 100644 --- a/src/command_line.coffee +++ b/src/command_line.coffee @@ -78,7 +78,7 @@ compile_scripts: -> else if opts.tree then puts coffee.tree(code).toString() else js: coffee.compile code - if opts.run then process.compile js, source + if opts.run then eval js else if opts.print then puts js else if opts.lint then lint js else write_js source, coffee.compile code