metalsmith-less
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -10,3 +10,9 @@ var async = require('async') | ||
return function (files, metalsmith, done) { | ||
async.each(Object.keys(files).filter(options.filter || all), convert.bind(null, parser, options, files), done) | ||
var paths | ||
try { | ||
paths = Object.keys(files).filter(options.filter || filter) | ||
} catch (ex) { | ||
return done(ex) | ||
} | ||
async.each(paths, convert.bind(null, parser, options, files), done) | ||
} | ||
@@ -17,6 +23,13 @@ } | ||
var data = files[path] | ||
if (!data || !data.contents) return done(new Error('data does not exist')) | ||
parser.parse(data.contents.toString(), function(err, tree){ | ||
if (err) return done(err) | ||
files[(options.mapPath || mapPath)(path)] = { | ||
contents: new Buffer(tree.toCSS(options.render || {})) | ||
var contents | ||
try { | ||
contents = tree.toCSS(options.render || {}) | ||
files[(options.mapPath || mapPath)(path, contents)] = { | ||
contents: new Buffer(contents) | ||
} | ||
} catch (ex) { | ||
return done(ex) | ||
} | ||
@@ -27,8 +40,8 @@ return done(null) | ||
function all(path) { | ||
function filter(path) { | ||
return /\.less$/.test(path) | ||
} | ||
function mapPath(path) { | ||
function mapPath(path, contents) { | ||
return path.replace(/less/g, 'css') | ||
} |
{ | ||
"name": "metalsmith-less", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A LESS plugin for Metalsmith", | ||
@@ -5,0 +5,0 @@ "main": "./lib/", |
# metalsmith-less | ||
A [LESS][0] plugin for [Metalsmith][3]. | ||
[![Build Status](https://travis-ci.org/christophercliff/metalsmith-less.png?branch=master)](https://travis-ci.org/christophercliff/metalsmith-less) | ||
A [LESS][less] plugin for [Metalsmith][metalsmith]. | ||
## Installation | ||
@@ -27,16 +29,22 @@ | ||
A function to filter source files. By default, includes all `.less` files. Use this to filter out [`@import`][1] files. | ||
A function to filter source files. By [default][default filter], includes all `.less` files. Use this to filter out [`@import`][less @import] files. | ||
#### `mapPath` | ||
A Function that maps source paths to build paths. By default, maps `less/your-file.less` to `css/your-file.css`. | ||
A function that maps source paths to build paths. By [default][default mapPath], maps `less/your-file.less` to `css/your-file.css`. | ||
#### `parse` | ||
An object that gets passed along to [`new less.Parser(options)`][2]. | ||
An object that gets passed along to [`new less.Parser(options)`][less source]. | ||
#### `render` | ||
An object that gets passed along to [`tree.toCSS(options)`][2]. | ||
An object that gets passed along to [`tree.toCSS(options)`][less source]. | ||
## Tests | ||
``` | ||
$ npm test | ||
``` | ||
## License | ||
@@ -46,5 +54,7 @@ | ||
[0]: http://lesscss.org/ | ||
[1]: http://lesscss.org/features/#features-overview-feature-importing | ||
[2]: https://github.com/less/less.js/ | ||
[3]: http://www.metalsmith.io/ | ||
[less]: http://lesscss.org/ | ||
[less @import]: http://lesscss.org/features/#features-overview-feature-importing | ||
[less source]: https://github.com/less/less.js/ | ||
[metalsmith]: http://www.metalsmith.io/ | ||
[default filter]: https://github.com/christophercliff/metalsmith-less/blob/master/lib/index.js#L38-L40 | ||
[default mapPath]: https://github.com/christophercliff/metalsmith-less/blob/master/lib/index.js#L42-L44 |
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
5109
10
56
59