Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added filename support to filter function so stylus imports can work

  • Loading branch information...
commit 8761a9c89c1d892c5da236c0a0f8c509ebbf9049 1 parent ae8674b
@Qard authored
Showing with 18 additions and 3 deletions.
  1. +17 −2 lib/index.js
  2. +1 −1  package.json
View
19 lib/index.js
@@ -131,8 +131,9 @@ Crsh.stylus = function () {
var self = this;
this.addType('css', 'styl')
- return function (file, next) {
+ return function (file, filename, next) {
stylus(file)
+ .set('filename', filename)
.set('paths', self.path)
.set('compress', isProd)
.set('filename', 'style.styl')
@@ -274,6 +275,7 @@ Crsh.prototype.remove = function (f) {
return this
}
+
/**
* Applies input filters to file map
*/
@@ -284,11 +286,23 @@ Crsh.prototype.applyInputFilters = function (files, cb) {
var filters = this.list.map(function (file) {
var fn = self.findFilter(path.extname(file))
return function (next) {
+ // Convert buffers to strings
files[file] = files[file].toString()
- fn(files[file], function (err, data) {
+
+ // Create dynamic arg list
+ var args = [files[file]]
+
+ // Add filename, if callback accepts it
+ (fn.length === 3) && args.push(file)
+
+ // Add receiver function
+ args.push(function (err, data) {
err || (files[file] = data)
next(err)
})
+
+ // Execute
+ fn.apply(null, args)
}
})
@@ -313,6 +327,7 @@ Crsh.prototype.compile = function (cb) {
Files.load(list, function (err, files) {
if (err) cb(err)
+ // Run through matching input filters
self.applyInputFilters(files, function (err, filteredFiles) {
if (err) { return cb(err) }
View
2  package.json
@@ -2,7 +2,7 @@
"author": "Stephen Belanger <admin@stephenbelanger.com> (http://stephenbelanger.com)",
"name": "crsh",
"description": "crsh your javascript and css into tiny blocks.",
- "version": "0.2.1",
+ "version": "0.2.3",
"repository": {
"url": "git://github.com/Qard/crsh.git"
},
Please sign in to comment.
Something went wrong with that request. Please try again.