first draft of mandatory parentheses around function definition param lists -- all tests pass

This commit is contained in:
Jeremy Ashkenas
2010-01-26 00:40:58 -05:00
parent 63b44a2b03
commit 460b3f6d8e
57 changed files with 1396 additions and 1561 deletions

View File

@@ -12,14 +12,14 @@ Readline: require('readline')
coffeePath: File.path(module.path).dirname().dirname().dirname().dirname().dirname().join('bin', 'coffee')
# Our general-purpose error handler.
checkForErrors: coffeeProcess =>
checkForErrors: (coffeeProcess) =>
return true if coffeeProcess.wait() is 0
system.stderr.print(coffeeProcess.stderr.read())
throw new Error("CoffeeScript compile error")
# Run a simple REPL, round-tripping to the CoffeeScript compiler for every
# command.
exports.run: args =>
exports.run: (args) =>
if args.length
for path, i in args
exports.evalCS(File.read(path))
@@ -35,24 +35,24 @@ exports.run: args =>
print(e)
# Compile a given CoffeeScript file into JavaScript.
exports.compileFile: path =>
exports.compileFile: (path) =>
coffee: OS.popen([coffeePath, "--print", "--no-wrap", path])
checkForErrors(coffee)
coffee.stdout.read()
# Compile a string of CoffeeScript into JavaScript.
exports.compile: source, flags =>
exports.compile: (source, flags) =>
coffee: OS.popen([coffeePath, "--eval", "--no-wrap"].concat(flags or []))
coffee.stdin.write(source).flush().close()
checkForErrors(coffee)
coffee.stdout.read()
# Evaluating a string of CoffeeScript first compiles it externally.
exports.evalCS: source, flags =>
exports.evalCS: (source, flags) =>
eval(exports.compile(source, flags))
# Make a factory for the CoffeeScript environment.
exports.makeNarwhalFactory: path =>
exports.makeNarwhalFactory: (path) =>
code: exports.compileFile(path)
factoryText: "function(require,exports,module,system,print){" + code + "/**/\n}"
if system.engine is "rhino"

View File

@@ -6,12 +6,12 @@ factories: {}
loader: {
# Reload the coffee-script environment from source.
reload: topId, path =>
reload: (topId, path) =>
coffeescript ||= require('coffee-script')
factories[topId]: => coffeescript.makeNarwhalFactory(path)
factories[topId]: () => coffeescript.makeNarwhalFactory(path)
# Ensure that the coffee-script environment is loaded.
load: topId, path =>
load: (topId, path) =>
factories[topId] ||= this.reload(topId, path)
}