Permalink
Browse files

Merge pull request #9 from RonnyPfannschmidt/filename-option

pass the filename option to coffeescript compile, fixes #8
  • Loading branch information...
2 parents c5479db + a70a46a commit e5e310d87ef5da65ff3aa6c872da0d471f9c06aa @nrw committed Mar 17, 2012
Showing with 11 additions and 11 deletions.
  1. +7 −7 build/compile.js
  2. +3 −3 build/remove.js
  3. +1 −1 src/compile.coffee
View
@@ -1,4 +1,5 @@
(function() {
+
module.exports = {
before: "modules",
run: function(root, path, settings, doc, callback) {
@@ -9,12 +10,8 @@
console.log("Coffee script precompiler must have either a modules or an attachment setting");
return callback(null, doc);
}
- if (modulesPaths == null) {
- modulesPaths = [];
- }
- if (attachmentsPaths == null) {
- attachmentsPaths = [];
- }
+ if (modulesPaths == null) modulesPaths = [];
+ if (attachmentsPaths == null) attachmentsPaths = [];
async = require("async");
utils = require("kanso-utils/utils");
precompiler = require("kanso-precompiler-base");
@@ -25,7 +22,9 @@
var js, name, rel;
rel = utils.relpath(filename, path);
console.log("Compiling attachment " + rel);
- js = coffee.compile(fs.readFileSync(filename, 'utf8'));
+ js = coffee.compile(fs.readFileSync(filename, 'utf8'), {
+ filename: filename
+ });
name = rel.replace(extension_pattern, ".js");
precompiler.addAttachment(doc, name, filename, js);
return callback(null, doc);
@@ -50,4 +49,5 @@
});
}
};
+
}).call(this);
View
@@ -1,14 +1,14 @@
(function() {
+
module.exports = {
after: "attachments",
run: function(root, path, settings, doc, callback) {
var k;
for (k in doc._attachments || {}) {
- if (/\.coffee$/.test(k)) {
- delete doc._attachments[k];
- }
+ if (/\.coffee$/.test(k)) delete doc._attachments[k];
}
return callback(null, doc);
}
};
+
}).call(this);
View
@@ -28,7 +28,7 @@ module.exports =
rel = utils.relpath(filename, path)
console.log("Compiling attachment #{rel}")
- js = coffee.compile(fs.readFileSync filename, 'utf8')
+ js = coffee.compile(fs.readFileSync(filename, 'utf8'), filename: filename)
name = rel.replace(extension_pattern, ".js")
precompiler.addAttachment(doc, name, filename,js)
callback(null, doc)

0 comments on commit e5e310d

Please sign in to comment.