metalsmith-loader
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -39,12 +39,21 @@ var path = require('path'); | ||
// Reduce list to scope. | ||
var names = this.options.scope.reduce(function(prev, current) { | ||
var deps = this.pkg[current] || []; | ||
return prev.concat(Array.isArray(deps) ? deps : Object.keys(deps)); | ||
// Module Name list | ||
this.names = []; | ||
}.bind(this), []); | ||
// Reduce + Match | ||
this.listReduce(); | ||
this.listMatch(); | ||
// Return | ||
return (this.options.global) ? '' : this.requires; | ||
}; | ||
/** | ||
* Match and add into require list | ||
*/ | ||
Plugins.prototype.listMatch = function(){ | ||
// Start the match | ||
multimatch(names, this.match).forEach(function(key){ | ||
multimatch(this.names, this.match).forEach(function(key){ | ||
@@ -57,3 +66,2 @@ var name = this.formatName(key); | ||
// When lazy, loads metalsmith in as well. | ||
@@ -63,6 +71,16 @@ if (this.options.core){ | ||
this.add('Metalsmith', require(mod)); | ||
} | ||
} | ||
}; | ||
// Return | ||
return (this.options.global) ? '' : this.requires; | ||
/** | ||
* Reducing List to the scope | ||
*/ | ||
Plugins.prototype.listReduce = function(){ | ||
this.names = this.options.scope.reduce(function(prev, current) { | ||
var deps = this.pkg[current] || []; | ||
return prev.concat(Array.isArray(deps) ? deps : Object.keys(deps)); | ||
}.bind(this), []); | ||
}; | ||
@@ -94,3 +112,2 @@ | ||
} | ||
}; | ||
@@ -108,4 +125,6 @@ | ||
for (var i in pattern){ | ||
var regex = new RegExp(pattern[i]); | ||
str = str.replace(regex, ''); | ||
if (pattern.hasOwnProperty(i)){ | ||
var regex = new RegExp(pattern[i]); | ||
str = str.replace(regex, ''); | ||
} | ||
} | ||
@@ -112,0 +131,0 @@ |
{ | ||
"name": "metalsmith-loader", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Loads Metalsmith as well as metalsmith plugins using globbing patterns similar to `load-grunt-task`", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
# metalsmith-loader | ||
> Loads Metalsmith as well as multiple metalsmith plugins using globbing patterns | ||
[![Build Status](https://travis-ci.org/yeojz/metalsmith-loader.svg?branch=master)](https://travis-ci.org/yeojz/metalsmith-loader) | ||
[![Dependency Status](https://david-dm.org/yeojz/metalsmith-loader.svg)](https://david-dm.org/yeojz/metalsmith-loader) | ||
[![devDependency Status](https://david-dm.org/yeojz/metalsmith-loader/dev-status.svg)](https://david-dm.org/yeojz/metalsmith-loader#info=devDependencies) | ||
[![Code Climate](https://codeclimate.com/github/yeojz/metalsmith-loader/badges/gpa.svg)](https://codeclimate.com/github/yeojz/metalsmith-loader) | ||
This plugin takes reference from / works similarly to [`load-grunt-task`](https://npmjs.org/package/load-grunt-tasks), allowing you to read the `dependencies`/`devDependencies`/`peerDependencies` in your package.json and load [metalsmith](http://metalsmith.io) plugins that matches the provided patterns. | ||
@@ -5,0 +10,0 @@ |
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
9645
13
178
99