Comparing version 0.9.0 to 0.9.1
0.9.1 / 2011-03-18 | ||
================== | ||
* Fixed connect middleware `@import` support. Closes #168 | ||
The middleware is now smart enough to know when imports | ||
change, and will re-compile the target file. | ||
* Changed middleware `compile` function to return the `Renderer` (API change) | ||
0.9.0 / 2011-03-18 | ||
@@ -3,0 +12,0 @@ ================== |
@@ -27,2 +27,8 @@ /*! | ||
/** | ||
* Import map. | ||
*/ | ||
var imports = {}; | ||
/** | ||
* Return Connect middleware with the given `options`. | ||
@@ -37,3 +43,3 @@ * | ||
* `compile` Custom compile function, accepting the arguments | ||
* `(str, path, callback)`. | ||
* `(str, path)`. | ||
* `compress` Whether the output .css files should be compressed | ||
@@ -49,7 +55,6 @@ * | ||
* | ||
* function compile(str, path, fn) { | ||
* stylus(str) | ||
* function compile(str, path) { | ||
* return stylus(str) | ||
* .set('filename', path) | ||
* .set('compress', true) | ||
* .render(fn); | ||
* .set('compress', true); | ||
* } | ||
@@ -69,3 +74,3 @@ * | ||
* }) | ||
* , connect.staticProvider(__dirname + '/public') | ||
* , connect.static(__dirname + '/public') | ||
* ); | ||
@@ -99,7 +104,6 @@ * | ||
// Default compile callback | ||
options.compile = options.compile || function(str, path, fn){ | ||
stylus(str) | ||
options.compile = options.compile || function(str, path){ | ||
return stylus(str) | ||
.set('filename', path) | ||
.set('compress', options.compress) | ||
.render(fn); | ||
.set('compress', options.compress); | ||
}; | ||
@@ -118,4 +122,4 @@ | ||
next(ENOENT == err.errno | ||
? null | ||
: err); | ||
? null | ||
: err); | ||
} | ||
@@ -130,3 +134,6 @@ | ||
if (err) return error(err); | ||
options.compile(str, stylusPath, function(err, css){ | ||
var style = options.compile(str, stylusPath); | ||
var paths = style.options._imports = []; | ||
style.render(function(err, css){ | ||
imports[stylusPath] = imports[stylusPath] || paths; | ||
if (err) return next(err); | ||
@@ -155,5 +162,8 @@ fs.writeFile(cssPath, css, 'utf8', function(err){ | ||
compile(); | ||
// Already compiled, defer serving | ||
// Already compiled, check imports | ||
} else { | ||
next(); | ||
checkImports(stylusPath, function(changed){ | ||
console.log(changed); | ||
changed ? compile() : next(); | ||
}); | ||
} | ||
@@ -167,2 +177,32 @@ } | ||
} | ||
}; | ||
}; | ||
/** | ||
* Check `path`'s imports to see if they have been altered. | ||
* | ||
* @param {String} path | ||
* @param {Function} fn | ||
* @api private | ||
*/ | ||
function checkImports(path, fn) { | ||
var nodes = imports[path]; | ||
if (!nodes) return fn(); | ||
if (!nodes.length) return fn(); | ||
var pending = nodes.length | ||
, changed = false; | ||
nodes.forEach(function(import){ | ||
fs.stat(import.path, function(err, stat){ | ||
if (err) { | ||
--pending || fn(changed); | ||
} else if (import.mtime) { | ||
changed = changed || stat.mtime > import.mtime; | ||
import.mtime = stat.mtime; | ||
--pending || fn(changed); | ||
} else { | ||
import.mtime = stat.mtime; | ||
--pending || fn(changed = true); | ||
} | ||
}); | ||
}); | ||
} |
@@ -26,3 +26,3 @@ | ||
exports.version = '0.9.0'; | ||
exports.version = '0.9.1'; | ||
@@ -29,0 +29,0 @@ /** |
{ "name": "stylus" | ||
, "description": "Robust, expressive language which compiles to CSS" | ||
, "version": "0.9.0" | ||
, "version": "0.9.1" | ||
, "author": "TJ Holowaychuk <tj@vision-media.ca>" | ||
@@ -5,0 +5,0 @@ , "keywords": ["css", "parser", "style", "stylesheets", "jade", "language"] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
195027
6713