Gulp plugin log output is only written for single file

84 Views Asked by At

I'm trying to write a gulp plugin for the first time. The plugin is later supposed to validate some styleguide requirements for all css and js files in a project.

In order to properly debug the plugin while testing, I want to use gutil.log() for printout. To get started, I created a gulp plugin which simply outputs the path of the tested file.

module.exports = function(){...};

function validate(file) {
    gutil.log(gutil.colors.yellow(file.path));
};

However, only one filename is printed in the gulp output. Debug shows, that all the correct files are listed with gulp.src(), but there is always only log output for a single file.

I then found the following here: Handle multiple files in a Gulp plugin

I tried using gulp-foreach with the following code:

gulp.task('head', function () {
    return gulp.src('./src/app/**/*.{css,js}')
        .pipe(foreach(function (stream, file) {
            return stream
                .pipe(validate());
        }));
});

But the result remains the same,there is only one log entry. I feel like I'm missing something very obvious here...

0

There are 0 best solutions below