function prettify(options) { return helper(options, false); }
n/a
function reporter(options) { var verbosity = 0; var errorCount = 0; if (typeof options === 'object' && Object.prototype.hasOwnProperty.call(options, 'verbosity')) { verbosity = options.verbosity; } return through.obj(function (file, encoding, callback) { if (file.jsbeautify) { if (verbosity >= 1 && file.jsbeautify.type === null) { log('Can not beautify ' + gutil.colors.cyan(file.relative)); } else if (verbosity >= 0 && file.jsbeautify.beautified) { log('Beautified ' + gutil.colors.cyan(file.relative) + ' [' + file.jsbeautify.type + ']'); } else if (verbosity >= 0 && file.jsbeautify.canBeautify) { errorCount += 1; log('Can beautify ' + gutil.colors.cyan(file.relative) + ' [' + file.jsbeautify.type + ']'); } else if (verbosity >= 1) { log('Already beautified ' + gutil.colors.cyan(file.relative) + ' [' + file.jsbeautify.type + ']'); } } callback(null, file); }, function flush(callback) { if (errorCount > 0) { this.emit('error', new PluginError(PLUGIN_NAME, 'Validation not passed. Please beautify.')); } callback(); }); }
...
```javascript
var gulp = require('gulp');
var prettify = require('gulp-jsbeautifier');
gulp.task('validate', function() {
return gulp.src(['./*.css', './*.html', './*.js'])
.pipe(prettify.validate())
.pipe(prettify.reporter())
});
```
## Reporter
Lists files that have been beautified, those already beautified, and those that can not be beautified.
If the [validate](#validate) feature is used, the reporter lists files that can be beautified and emits an error before the stream
ends if such a file was detected.
...
function validate(options) { return helper(options, true); }
...
```javascript
var gulp = require('gulp');
var prettify = require('gulp-jsbeautifier');
gulp.task('validate', function() {
return gulp.src(['./*.css', './*.html', './*.js'])
.pipe(prettify.validate())
.pipe(prettify.reporter())
});
```
## Reporter
Lists files that have been beautified, those already beautified, and those that can not be beautified.
If the [validate](#validate) feature is used, the reporter lists files that can be beautified and emits an error before the stream
ends if such a file was detected.
...