Skip to content

Commit

Permalink
add filename with relative path to syntax errors for modules and atta…
Browse files Browse the repository at this point in the history
…chments. version bump.
  • Loading branch information
nrw committed Mar 17, 2012
1 parent e5e310d commit fd880a6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
16 changes: 10 additions & 6 deletions build/compile.js
@@ -1,5 +1,4 @@
(function() {

module.exports = {
before: "modules",
run: function(root, path, settings, doc, callback) {
Expand All @@ -10,8 +9,12 @@
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");
Expand All @@ -23,7 +26,7 @@
rel = utils.relpath(filename, path);
console.log("Compiling attachment " + rel);
js = coffee.compile(fs.readFileSync(filename, 'utf8'), {
filename: filename
filename: rel
});
name = rel.replace(extension_pattern, ".js");
precompiler.addAttachment(doc, name, filename, js);
Expand All @@ -33,7 +36,9 @@
var js, name, rel;
rel = utils.relpath(filename, path);
console.log("Compiling module " + rel);
js = coffee.compile(fs.readFileSync(filename, 'utf8'));
js = coffee.compile(fs.readFileSync(filename, 'utf8'), {
filename: rel
});
name = rel.replace(extension_pattern, "");
precompiler.addModule(doc, name, filename, js);
return callback(null, doc);
Expand All @@ -49,5 +54,4 @@
});
}
};

}).call(this);
6 changes: 3 additions & 3 deletions build/remove.js
@@ -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);
2 changes: 1 addition & 1 deletion kanso.json
@@ -1,6 +1,6 @@
{
"name": "coffee-script-precompiler",
"version": "1.2.0-kanso.1",
"version": "1.2.0-kanso.2",
"categories": ["build-tools"],
"description": "Compiles CoffeeScript modules and attachments to javascript on each push",
"url": "https://github.com/nrw/coffee-script-precompiler/",
Expand Down
4 changes: 2 additions & 2 deletions src/compile.coffee
Expand Up @@ -28,7 +28,7 @@ module.exports =
rel = utils.relpath(filename, path)
console.log("Compiling attachment #{rel}")

js = coffee.compile(fs.readFileSync(filename, 'utf8'), filename: filename)
js = coffee.compile fs.readFileSync(filename, 'utf8'), filename: rel
name = rel.replace(extension_pattern, ".js")
precompiler.addAttachment(doc, name, filename,js)
callback(null, doc)
Expand All @@ -38,7 +38,7 @@ module.exports =
rel = utils.relpath(filename, path)
console.log("Compiling module #{rel}")

js = coffee.compile(fs.readFileSync filename, 'utf8')
js = coffee.compile fs.readFileSync(filename, 'utf8'), filename: rel
name = rel.replace(extension_pattern, "")
precompiler.addModule(doc, name, filename, js)
callback(null, doc)
Expand Down

0 comments on commit fd880a6

Please sign in to comment.