made the path handling a little more robust

This commit is contained in:
Jeremy Ashkenas
2010-01-29 23:41:18 -05:00
parent f5a37035cf
commit b0ecb39e9f
4 changed files with 20 additions and 6 deletions

View File

@@ -1,10 +1,15 @@
# Executes the `coffee` Ruby program to convert from CoffeeScript to JavaScript.
sys: require('sys')
sys: require('sys')
path: require('path')
# The path to the CoffeeScript executable.
compiler: path.normalize(path.dirname(__filename) + '/../../bin/coffee')
# Compile a string over stdin, with global variables, for the REPL.
exports.compile: (code, callback) ->
js: ''
coffee: process.createChildProcess 'coffee', ['--eval', '--no-wrap', '--globals']
coffee: process.createChildProcess compiler, ['--eval', '--no-wrap', '--globals']
coffee.addListener 'output', (results) ->
js += results if results?
coffee.addListener 'exit', ->
@@ -12,9 +17,10 @@ exports.compile: (code, callback) ->
coffee.write(code)
coffee.close()
# Compile a list of CoffeeScript files on disk.
exports.compile_files: (paths, callback) ->
js: ''
coffee: process.createChildProcess 'coffee', ['--print'].concat(paths)
coffee: process.createChildProcess compiler, ['--print'].concat(paths)
coffee.addListener 'output', (results) ->
js += results if results?
coffee.addListener 'exit', ->