/**
 * Created by iraquitan on 9/2/16.
 */
/* eslint-env node */
/* eslint-disable no-console */

var gulp = require("gulp");
var sass = require("gulp-sass");
var sourceMaps = require("gulp-sourcemaps");
var jekyll = require("gulp-jekyll-stream");
var ghPages = require("gulp-gh-pages");
var autoprefixer = require("gulp-autoprefixer");
var imagemin = require("gulp-imagemin");
var uglify = require("gulp-uglify");
var pump = require("pump");

gulp.task("default", function () {
    console.log("Gulp running...");
});

gulp.task("jekyll", ["styles", "imagemin", "script"], function () {
    return gulp.src(process.cwd())
        .pipe(jekyll({
            bundleExec: true,              // exec jekyll w/ "bundle exec"
            quiet: true,                   // suppress jekyll output; implies "--trace"
            safe: false,                   // run Jekyll in "safe" mode
            cwd: process.cwd(),            // below paths will be relative to this
            layouts: "_layouts",           // where your layouts live
            plugins: "_plugins"            // where your plugins live
            // source: '/path/to/source'   // overrides gulp.src() above
            // destination: '_site'        // can be used instead of gulp.dest()
        }))
        .pipe(gulp.dest("_site"));
});

gulp.task("deploy", function () {
    return gulp.src("_site")
        .pipe(ghPages({
            branch: "master"
        }));
});

gulp.task("styles", function () {
    gulp.src("_sass/**/*.scss")
        .pipe(sourceMaps.init())
        .pipe(sass({outputStyle: "compressed"}).on("error", sass.logError))
        .pipe(autoprefixer({
            browsers: ["last 2 versions"]
        }))
        .pipe(sourceMaps.write())
        .pipe(gulp.dest("_site/assets/css"));
});

gulp.task("imagemin", function () {
    gulp.src("assets/img/*")
        .pipe(imagemin({
            progressive: true
        }))
        .pipe(gulp.dest("_site/assets/img"));
});

gulp.task("script", function () {
    pump([
        gulp.src("assets/js/*.js"),
        sourceMaps.init(),
        uglify(),
        sourceMaps.write(),
        gulp.dest("_site/assets/js")
    ]);
});
@@ -367,24 +367,98 @@
 imagemin%22);%0A
+var eslint = require(%22gulp-eslint%22);%0Avar concat = require(%22gulp-concat%22);%0A
 var uglify =
@@ -610,42 +610,8 @@
 ll%22,
- %5B%22styles%22, %22imagemin%22, %22script%22%5D,
  fun
@@ -1359,13 +1359,109 @@
 k(%22d
-eploy
+ist%22, %5B%22jekyll%22, %22styles%22, %22imagemin%22, %22lint%22, %22scripts-dist%22%5D, function () %7B%7D);%0A%0Agulp.task(%22gh-pages
 %22, f
@@ -1499,16 +1499,21 @@
 c(%22_site
+/**/*
 %22)%0A     
@@ -1559,27 +1559,151 @@
 %22master%22
-%0A        %7D)
+,%0A            force: true%0A        %7D));%0A%7D);%0A%0Agulp.task(%22deploy%22, %5B%22dist%22, %22gh-pages%22%5D, function () %7B%0A    console.log(%22deploy task done.%22
 );%0A%7D);%0A%0A
@@ -2107,16 +2107,19 @@
 ts/img/*
+*/*
 %22)%0A     
@@ -2248,16 +2248,180 @@
 (%22script
+s%22, function () %7B%0A    pump(%5B%0A        gulp.src(%22assets/js/*.js%22),%0A        concat(%22all.js%22),%0A        gulp.dest(%22_site/assets/js%22)%0A    %5D);%0A%7D);%0A%0Agulp.task(%22scripts-dist
 %22, funct
@@ -2499,24 +2499,50 @@
 aps.init(),%0A
+        concat(%22all.js%22),%0A
         ugli
@@ -2603,28 +2603,831 @@
 site/assets/js%22)%0A    %5D);%0A%7D);
+%0A%0Agulp.task(%22lint%22, function () %7B%0A    // ESLint ignores files with %22node_modules%22 paths.%0A    // So, it's best to have gulp ignore the directory as well.%0A    // Also, Be sure to return the stream from the task;%0A    // Otherwise, the task may end before the stream has finished.%0A    return gulp.src(%5B%22assets/js/**/*.js%22%5D)%0A    // eslint() attaches the lint output to the %22eslint%22 property%0A    // of the file object so it can be used by other modules.%0A        .pipe(eslint())%0A        // eslint.format() outputs the lint results to the console.%0A        // Alternatively use eslint.formatEach() (see Docs).%0A        .pipe(eslint.format());%0A    // To have the process exit with an error code (1) on%0A    // lint error, return the stream and pipe to failAfterError last.%0A    // .pipe(eslint.failAfterError());%0A%7D);

Add lint, dist, deploy and scripts-dist tasks