var gulp = require('gulp'); 
var jshint = require('gulp-jshint');
var prettify = require('gulp-prettify');
var markdown = require('gulp-markdown');

gulp.task('default', function() {
  gulp.src('./*.js')
    .pipe(jshint())
    .pipe(jshint.reporter('default'));

  gulp.src('./hosts/*.js')
    .pipe(jshint())
    .pipe(jshint.reporter('default'));

  gulp.src('./*.md')
    .pipe(markdown())
    .pipe(gulp.dest('./'));
    
  gulp.src('./docs/*.md')
    .pipe(markdown())
    .pipe(gulp.dest('./docs/'));
});

gulp.task('watch', function() {
    gulp.watch('./*.js', ['default']);
    gulp.watch('./*.md', ['default']);
    gulp.watch('./docs/*.md', ['defult']);
    gulp.watch('./hosts/*.js', ['default']);
});

gulp.task('prettify', function () {
  gulp.src('./*.js')
    .pipe(prettify({collapseWhitespace: true}))
    .pipe(gulp.dest('./'));
    
  gulp.src('./hosts/*.js')
    .pipe(prettify({collapseWhitespace: true}))
    .pipe(gulp.dest('./hosts'));
});
