johnpapa / gulp-patterns

Playground for Gulp Recipes
501 stars 146 forks source link

I think i found a bug in the inject function #122

Open stefanaerts opened 8 years ago

stefanaerts commented 8 years ago

John I believe i found a bug in the inject/order functions. The read option {read: false} is given to the gulp-inject function instead of the gulp.src. So i got this error because of it: [14:35:17] Wiring the bower dependencies into the html [14:35:17] 'wiredep' errored after 51 ms [14:35:17] Error in plugin 'gulp-inject' Message: There is no read option. Did you mean to provide it for gulp.src perhaps?

Rg, Stefan

stefanaerts commented 8 years ago

John, it seems that the older version of gulp-inject didn't check on this read option.

gulp-inject@1.5.0 you use doesn't check on that.

gulp-inject@4.1.0 does the check and thats why i found the bug.

OR it could be that there was a read option in gulp-inject@1.5.1 and not any more on gulp-inject@4.1.0,but i doubt that. I guess you want to have a read-false on the src files, so then the code in the inject and order function is wrong. So I suggest my update.

stefanaerts commented 8 years ago

This is my update how i believe it should be:

function inject(src, label, order) { var options = {read: false}; if (label) { return $.inject(orderSrc(src, order,options),{name:'inject:' + label}); } else { return $.inject(orderSrc(src, order,options)); } }

function orderSrc(src, order,options) { //order = order || ['* /']; return gulp .src(src,options) .pipe($.if(order, $.order(order))); }