gulp-recipe-loader
Advanced tools
Comparing version 0.1.10 to 0.1.11
20
main.js
@@ -90,2 +90,4 @@ 'use strict'; | ||
var allRecipesInitalized = false; | ||
// set default options | ||
@@ -234,2 +236,14 @@ options = _.merge({ | ||
var processSourceHook = _.once(function () { | ||
// This hook function is evaluated on first source pipe usage, | ||
// which means inside a specific task, after all recipes are successfuly loaded. | ||
// It's safe to grab pipe hooks from there, unles a specific plugin | ||
// decides to evaluate pipe before initialization. Yell at it! | ||
if(!allRecipesInitalized) { | ||
throw new $.utils.RecipeError('Stream created before all recipes are initialized.'); | ||
} | ||
return $.utils.sequentialLazypipe($.utils.getPipes('processSource')); | ||
}); | ||
// prepare lazy initializers for recipes, so it may be cross referenced | ||
@@ -256,3 +270,5 @@ $.recipes = {}; | ||
} | ||
sources = localLibs.utils.makeSources(localConfig.sources); | ||
sources = localLibs.utils.makeSources(localConfig.sources, function () { | ||
return processSourceHook()(); | ||
}); | ||
} | ||
@@ -287,3 +303,5 @@ | ||
allRecipesInitalized = true; | ||
return $; | ||
}; |
{ | ||
"name": "gulp-recipe-loader", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"description": "Gulp environment with receipe modules autoloading with hooks", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
@@ -43,3 +43,3 @@ 'use strict'; | ||
*/ | ||
function makeSources(sourceDefs) { | ||
function makeSources(sourceDefs, sourceProcessor) { | ||
var defaultBase = _.isUndefined(sourceDefs.defaultBase) ? '.' : sourceDefs.defaultBase; | ||
@@ -52,3 +52,7 @@ | ||
try { | ||
return libSource.make(source, $.gulp.src, defaultBase); | ||
var stream = libSource.make(source, $.gulp.src, defaultBase); | ||
if(_.isFunction(sourceProcessor)) { | ||
return stream.pipe(sourceProcessor); | ||
} | ||
return stream; | ||
} | ||
@@ -55,0 +59,0 @@ catch (e) { |
Sorry, the diff of this file is not supported yet
40762
1004