Created
March 6, 2013 12:40
-
-
Save richthegeek/5099033 to your computer and use it in GitHub Desktop.
Modified builder-coffee which takes .coffee files directly from teh "scripts" directive of a component.json file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs = require( 'fs' ) | |
CoffeeScript = require( 'coffee-script' ) | |
module.exports = ( builder )-> | |
builder.hook 'before scripts', ( pkg )-> | |
if scripts = pkg.conf.scripts | |
ret_scripts = [] | |
scripts.forEach (file) -> | |
name = file.match /^(.+)\.coffee$/i | |
if name | |
source = fs.readFileSync file, 'utf8' | |
compiled = CoffeeScript.compile source, bare: yes | |
file = name[1] + '.js' | |
fs.writeFileSync file, compiled, 'utf-8' | |
ret_scripts.push file | |
pkg.conf.scripts = ret_scripts | |
return pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generated by CoffeeScript 1.5.0 | |
(function() { | |
var CoffeeScript, fs; | |
fs = require('fs'); | |
CoffeeScript = require('coffee-script'); | |
module.exports = function(builder) { | |
return builder.hook('before scripts', function(pkg) { | |
var ret_scripts, scripts; | |
if (scripts = pkg.conf.scripts) { | |
ret_scripts = []; | |
scripts.forEach(function(file) { | |
var compiled, name, source; | |
name = file.match(/^(.+)\.coffee$/i); | |
if (name) { | |
source = fs.readFileSync(file, 'utf8'); | |
compiled = CoffeeScript.compile(source, { | |
bare: true | |
}); | |
file = name[1] + '.js'; | |
fs.writeFileSync(file, compiled, 'utf-8'); | |
} | |
return ret_scripts.push(file); | |
}); | |
} | |
pkg.conf.scripts = ret_scripts; | |
return pkg; | |
}); | |
}; | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment