mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 02:51:25 -05:00
got a build script for rebuilding the compiler, too
This commit is contained in:
12
build.coffee
12
build.coffee
@@ -4,10 +4,22 @@
|
|||||||
|
|
||||||
fs: require 'fs'
|
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.
|
# Print the usage message for the build scripts.
|
||||||
usage: ->
|
usage: ->
|
||||||
puts "build.coffee usage goes here..."
|
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.
|
# Rebuild the Jison parser from the compiled lib/grammar.js file.
|
||||||
build_parser: ->
|
build_parser: ->
|
||||||
parser: require('grammar').parser
|
parser: require('grammar').parser
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
} else {
|
} else {
|
||||||
js = coffee.compile(code);
|
js = coffee.compile(code);
|
||||||
if (opts.run) {
|
if (opts.run) {
|
||||||
process.compile(js, source);
|
eval(js);
|
||||||
} else if (opts.print) {
|
} else if (opts.print) {
|
||||||
puts(js);
|
puts(js);
|
||||||
} else if (opts.lint) {
|
} else if (opts.lint) {
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ compile_scripts: ->
|
|||||||
else if opts.tree then puts coffee.tree(code).toString()
|
else if opts.tree then puts coffee.tree(code).toString()
|
||||||
else
|
else
|
||||||
js: coffee.compile code
|
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.print then puts js
|
||||||
else if opts.lint then lint js
|
else if opts.lint then lint js
|
||||||
else write_js source, coffee.compile code
|
else write_js source, coffee.compile code
|
||||||
|
|||||||
Reference in New Issue
Block a user