Move layout check

This commit is contained in:
ismay 2015-09-19 12:39:36 +02:00
parent b4fc99b730
commit 43e80e2ab3
2 changed files with 9 additions and 10 deletions

View file

@ -17,10 +17,10 @@ module.exports = check;
* @param {String} pattern
* @return {Boolean}
*/
function check(files, file, pattern){
function check(files, file, pattern, def){
var data = files[file];
// Don't process binary files
// Only process utf8 encoded files (so no binary)
if (!utf8(data.contents)) {
return false;
}
@ -30,5 +30,10 @@ function check(files, file, pattern){
return false;
}
// Only process files with a specified layout
if(!data.layout && !def) {
return false;
}
return true;
}

View file

@ -36,7 +36,6 @@ var settings = ['default', 'directory', 'engine', 'partials', 'pattern'];
* @property {String} pattern (optional)
* @return {Function}
*/
function plugin(opts){
/**
* Init
@ -87,10 +86,10 @@ function plugin(opts){
}
/**
* Stringify files that pass the check, and store in matches
* Stringify files that pass the check, pass to matches
*/
Object.keys(files).forEach(function(file){
if (!check(files, file, pattern)) {
if (!check(files, file, pattern, def)) {
return;
}
@ -107,11 +106,6 @@ function plugin(opts){
debug('converting file: %s', file);
var data = files[file];
// Ignore files without a specified layout
if(!data.layout && !def) {
return done();
}
// Deep clone params (by passing 'true')
var clonedParams = extend(true, {}, params);
var clone = extend({}, clonedParams, metadata, data);