Permalink
Browse files

Added a command line option to specify the compiler, which defaults t…

…o coffee. Removed hardcoded use of iced compiler and allow compilation from anything that supports the same command line arguments as coffee.
  • Loading branch information...
1 parent 32cccc6 commit 61b67c29fc844e6b9c5f092bce795fd09e57efe5 @Akkuma Akkuma committed May 29, 2012
Showing with 9 additions and 15 deletions.
  1. +5 −0 lib/node.io/interfaces/cli.js
  2. +1 −1 lib/node.io/processor.js
  3. +3 −14 lib/node.io/utils.js
View
5 lib/node.io/interfaces/cli.js
@@ -30,6 +30,7 @@ var usage = ''
+ ' -g, --debug Debug the operation\n'
+ ' -v, --version Display the current version\n'
+ ' -h, --help Display help information\n'
+ + ' -c, --compiler Set an alternate compiler to use\n'
;
/**
@@ -118,6 +119,10 @@ exports.cli = function (args, exit) {
case '--unpack':
options.unpack = args.shift();
break;
+ case '-c':
+ case '--compiler':
+ options.compiler = args.shift();
+ break;
default:
job_path = arg;
if (args.length) {
View
2 lib/node.io/processor.js
@@ -335,7 +335,7 @@ Processor.prototype.loadJob = function (job, options, callback) {
//If we're the master, compile and load the .coffee file
this.status('Compiling ' + job + ' => ' + compiled_js, 'debug');
- utils.compileCoffee(job, compiled_js, function(err) {
+ utils.compile(options.compiler || 'coffee', job, compiled_js, function(err) {
if (err) {
callback(err);
} else {
View
17 lib/node.io/utils.js
@@ -78,21 +78,10 @@ exports.removeOnExit = function (file) {
* @param {Function} callback
* @api public
*/
-exports.compileCoffee = function (coffee_file, compiled_file, callback) {
- exec('iced -p -c "' + coffee_file + '"', {cwd: cwd}, function (err, stdout, stderr) {
+exports.compile = function (compiler, coffee_file, compiled_file, callback) {
+ exec(compiler + ' -p -c "' + coffee_file + '"', {cwd: cwd}, function (err, stdout, stderr) {
if (err || stderr) {
- if (!stderr || (stderr && stderr.indexOf("iced: not found") === -1)) {
- callback(err || stderr);
- } else {
- exec('coffee -p -c "' + coffee_file + '"', {cwd: cwd}, function (err, stdout, stderr) {
- if (err || stderr) {
- callback(err || stderr);
- } else {
- exports.removeOnExit(compiled_file);
- fs.writeFile(compiled_file, stdout, callback);
- }
- });
- }
+ callback(err || stderr);
} else {
exports.removeOnExit(compiled_file);
fs.writeFile(compiled_file, stdout, callback);

0 comments on commit 61b67c2

Please sign in to comment.