0

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...

Community
  • 1
  • 1
Diana
  • 75
  • 1
  • 9
  • Can you post a sample output before and after the foreach? – Wilmer SH Aug 02 '16 at 14:28
  • Not sure what you mean, if I add console.log before and after, they are both posted between the "Starting head" and "Finished head" messages, afterwards there is a single line with one filename out of all the files that should be checked. – Diana Aug 02 '16 at 15:19
  • Ok, I got it to work now by using the gulp-xml-validator plugin as a basis. It also doesn't need foreach, it simply works by itself. – Diana Aug 03 '16 at 07:38

0 Answers0