mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-17 19:11:22 -05:00
made the path handling a little more robust
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
(function(){
|
||||
var sys;
|
||||
var compiler, path, sys;
|
||||
// Executes the `coffee` Ruby program to convert from CoffeeScript to JavaScript.
|
||||
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 = function compile(code, callback) {
|
||||
var coffee, js;
|
||||
js = '';
|
||||
coffee = process.createChildProcess('coffee', ['--eval', '--no-wrap', '--globals']);
|
||||
coffee = process.createChildProcess(compiler, ['--eval', '--no-wrap', '--globals']);
|
||||
coffee.addListener('output', function(results) {
|
||||
if ((typeof results !== "undefined" && results !== null)) {
|
||||
return js += results;
|
||||
@@ -17,10 +21,11 @@
|
||||
coffee.write(code);
|
||||
return coffee.close();
|
||||
};
|
||||
// Compile a list of CoffeeScript files on disk.
|
||||
exports.compile_files = function compile_files(paths, callback) {
|
||||
var coffee, js;
|
||||
js = '';
|
||||
coffee = process.createChildProcess('coffee', ['--print'].concat(paths));
|
||||
coffee = process.createChildProcess(compiler, ['--print'].concat(paths));
|
||||
coffee.addListener('output', function(results) {
|
||||
if ((typeof results !== "undefined" && results !== null)) {
|
||||
return js += results;
|
||||
|
||||
Reference in New Issue
Block a user