reporters/file.js
function(callback) {
            var stream = this;

            // We don't need to write an empty file.
            if (collectedErrors.length === 0) {
                callback();

                return;
            }

            var report = collectedErrors.join('\n\n').trim() + '\n';

            // Write the error output to the defined file
            fs.writeFile(options.path, report, function(err) {
                if (err) {
                    stream.emit('error', new gutil.PluginError('gulp-phpcs', err));
                    callback();

                    return;
                }

                // Build console info message
                var message = util.format(
                    'Your PHPCS report with %s got written to %s',
                    chalk.red(pluralize('error', collectedErrors.length, true)),
                    chalk.magenta(options.path)
                );

                // And output it.
                gutil.log(message);

                callback();
            });
        }
function(callback) {
            var stream = this;

            // We don't need to write an empty file.
            if (collectedErrors.length === 0) {
                callback();

                return;
            }

            var report = collectedErrors.join('\n\n').trim() + '\n';

            // Write the error output to the defined file
            fs.writeFile(options.path, report, function(err) {
                if (err) {
                    stream.emit('error', new gutil.PluginError('gulp-phpcs', err));
                    callback();

                    return;
                }

                // Build console info message
                var message = util.format(
                    'Your PHPCS report with %s got written to %s',
                    chalk.red(pluralize('error', collectedErrors.length, true)),
                    chalk.magenta(options.path)
                );

                // And output it.
                gutil.log(message);

                callback();
            });
        }
function ( callback ) { var stream = this ; // We don't need to write an empty file. if ( collectedErrors . length === 0 ) { callback ( ) ; return ; } var report = collectedErrors . join ( '\n\n' ) . trim ( ) + '\n' ; // Write the error output to the defined file fs . writeFile ( options . path , report , function ( err ) { if ( err ) { stream . emit ( 'error' , new gutil . PluginError ( 'gulp-phpcs' , err ) ) ; callback ( ) ; return ; } // Build console info message var message = util . format ( 'Your PHPCS report with %s got written to %s' , chalk . red ( pluralize ( 'error' , collectedErrors . length , true ) ) , chalk . magenta ( options . path ) ) ; // And output it. gutil . log ( message ) ; callback ( ) ; } ) ; }
After we collected all errors, output them to the defined file.
After we collected all errors output them to the defined file .