<commit_before>/**
 * @author  Jozef Butko
 * @url		  www.jozefbutko.com/resume
 * @date    March 2015
 * @license MIT
 *
 * AngularJS Boilerplate: Build, watch and other useful tasks
 *
 * The build process consists of following steps:
 * 1. clean /_build folder
 * 2. compile SASS files, minify and uncss compiled css
 * 3. copy and minimize images
 * 4. minify and copy all HTML files into $templateCache
 * 5. build index.html
 * 6. minify and copy all JS files
 * 7. copy fonts
 * 8. show build folder size
 *
 */
var gulp            = require('gulp'),
    browserSync     = require('browser-sync'),
    reload          = browserSync.reload,
    $               = require('gulp-load-plugins')(),
    del             = require('del'),
    runSequence     = require('run-sequence');

// optimize images
gulp.task('images', function() {
  return gulp.src('./images/*')
    .pipe($.changed('./_build/images'))
    .pipe($.imagemin({
      optimizationLevel: 3,
      progressive: true,
      interlaced: true
    }))
    .pipe(gulp.dest('./_build/images'));
});

// browser-sync task, only cares about compiled CSS
gulp.task('browser-sync', function() {
  browserSync({
    server: {
      baseDir: "./"
    }
  });
});

// minify JS
gulp.task('minify-js', function() {
  gulp.src('js/*.js')
    .pipe($.uglify())
    .pipe(gulp.dest('./_build/'));
});

// minify CSS
gulp.task('minify-css', function() {
  gulp.src(['./styles/**/*.css', '!./styles/**/*.min.css'])
    .pipe($.rename({suffix: '.min'}))
    .pipe($.minifyCss({keepBreaks:true}))
    .pipe(gulp.dest('./styles/'))
    .pipe(gulp.dest('./_build/css/'));
});

// minify HTML
gulp.task('minify-html', function() {
  var opts = {
    comments: true,
    spare: true,
    conditionals: true
  };

  gulp.src('./*.html')
    .pipe($.minifyHtml(opts))
    .pipe(gulp.dest('./_build/'));
});

// copy fonts from a module outside of our project (like Bower)
gulp.task('fonts', function() {
  gulp.src('./fonts/**/*.{ttf,woff,eof,eot,svg}')
    .pipe($.changed('./_build/fonts'))
    .pipe(gulp.dest('./_build/fonts'));
});

// start webserver
gulp.task('server', function(done) {
  return browserSync({
    server: {
      baseDir: './'
    }
  }, done);
});

// start webserver from _build folder to check how it will look in production
gulp.task('server-build', function(done) {
  return browserSync({
    server: {
      baseDir: './_build/'
    }
  }, done);
});

// delete build folder
gulp.task('clean:build', function (cb) {
  del([
    './_build/'
    // if we don't want to clean any file we can use negate pattern
    //'!dist/mobile/deploy.json'
  ], cb);
});

// concat files
gulp.task('concat', function() {
  gulp.src('./js/*.js')
    .pipe($.concat('scripts.js'))
    .pipe(gulp.dest('./_build/'));
});

// SASS task, will run when any SCSS files change & BrowserSync
// will auto-update browsers
gulp.task('sass', function() {
  return gulp.src('styles/style.scss')
    .pipe($.sourcemaps.init())
    .pipe($.sass({
      style: 'expanded'
    }))
    .on('error', $.notify.onError({
      title: 'SASS Failed',
      message: 'Error(s) occurred during compile!'
    }))
    .pipe($.sourcemaps.write())
    .pipe(gulp.dest('styles'))
    .pipe(reload({
      stream: true
    }))
    .pipe($.notify({
      message: 'Styles task complete'
    }));
});

// SASS Build task
gulp.task('sass:build', function() {
  var s = $.size();

  return gulp.src('styles/style.scss')
    .pipe($.sass({
      style: 'compact'
    }))
    .pipe($.autoprefixer('last 3 version'))
    .pipe($.uncss({
      html: ['./index.html', './views/**/*.html', './components/**/*.html'],
      ignore: [
        '.index',
        '.slick',
        /\.owl+/,
        /\.owl-next/,
        /\.owl-prev/
      ]
    }))
    .pipe($.minifyCss({
      keepBreaks: true,
      aggressiveMerging: false,
      advanced: false
    }))
    .pipe($.rename({suffix: '.min'}))
    .pipe(gulp.dest('_build/css'))
    .pipe(s)
    .pipe($.notify({
      onLast: true,
      message: function() {
        return 'Total CSS size ' + s.prettySize;
      }
    }));
});

// BUGFIX: warning: possible EventEmitter memory leak detected. 11 listeners added.
require('events').EventEmitter.prototype._maxListeners = 100;

// index.html build
// script/css concatenation
gulp.task('usemin', function() {
  return gulp.src('./index.html')
    // add templates path
    .pipe($.htmlReplace({
      'templates': '<script type="text/javascript" src="js/templates.js"></script>'
    }))
    .pipe($.usemin({
      css: [$.minifyCss(), 'concat'],
      libs: [$.uglify()],
      nonangularlibs: [$.uglify()],
      angularlibs: [$.uglify()],
      appcomponents: [$.uglify()],
      mainapp: [$.uglify()]
    }))
    .pipe(gulp.dest('./_build/'));
});

// make templateCache from all HTML files
gulp.task('templates', function() {
  return gulp.src([
      './**/*.html',
      '!bower_components/**/*.*',
      '!node_modules/**/*.*',
      '!_build/**/*.*'
    ])
    .pipe($.minifyHtml())
    .pipe($.angularTemplatecache({
      module: 'boilerplate'
    }))
    .pipe(gulp.dest('_build/js'));
});

// reload all Browsers
gulp.task('bs-reload', function() {
  browserSync.reload();
});

// calculate build folder size
gulp.task('build:size', function() {
  var s = $.size();

  return gulp.src('./_build/**/*.*')
    .pipe(s)
    .pipe($.notify({
      onLast: true,
      message: function() {
        return 'Total build size ' + s.prettySize;
      }
    }));
});

// default task to be run with `gulp` command
// this default task will run BrowserSync & then use Gulp to watch files.
// when a file is changed, an event is emitted to BrowserSync with the filepath.
gulp.task('default', ['browser-sync', 'sass', 'minify-css'], function() {
  gulp.watch('styles/*.css', function(file) {
    if (file.type === "changed") {
      reload(file.path);
    }
  });
  gulp.watch(['*.html', 'views/*.html'], ['bs-reload']);
  gulp.watch(['app/*.js', 'components/**/*.js', 'js/*.js'], ['bs-reload']);
  gulp.watch('styles/**/*.scss', ['sass', 'minify-css']);
});

/**
 * build task:
 * 1. clean /_build folder
 * 2. compile SASS files, minify and uncss compiled css
 * 3. copy and minimize images
 * 4. minify and copy all HTML files into $templateCache
 * 5. build index.html
 * 6. minify and copy all JS files
 * 7. copy fonts
 * 8. show build folder size
 *
 */
gulp.task('build', function(callback) {
  runSequence(
    'clean:build',
    'sass:build',
    'images',
    'templates',
    'usemin',
    'fonts',
    'build:size',
    callback);
});<commit_msg>updated gulpfile so it recurses in image directory.<commit_after>/**
 * @author  Jozef Butko
 * @url		  www.jozefbutko.com/resume
 * @date    March 2015
 * @license MIT
 *
 * AngularJS Boilerplate: Build, watch and other useful tasks
 *
 * The build process consists of following steps:
 * 1. clean /_build folder
 * 2. compile SASS files, minify and uncss compiled css
 * 3. copy and minimize images
 * 4. minify and copy all HTML files into $templateCache
 * 5. build index.html
 * 6. minify and copy all JS files
 * 7. copy fonts
 * 8. show build folder size
 *
 */
var gulp            = require('gulp'),
    browserSync     = require('browser-sync'),
    reload          = browserSync.reload,
    $               = require('gulp-load-plugins')(),
    del             = require('del'),
    runSequence     = require('run-sequence');

// optimize images
gulp.task('images', function() {
  return gulp.src('./images/**/*')
    .pipe($.changed('./_build/images'))
    .pipe($.imagemin({
      optimizationLevel: 3,
      progressive: true,
      interlaced: true
    }))
    .pipe(gulp.dest('./_build/images'));
});

// browser-sync task, only cares about compiled CSS
gulp.task('browser-sync', function() {
  browserSync({
    server: {
      baseDir: "./"
    }
  });
});

// minify JS
gulp.task('minify-js', function() {
  gulp.src('js/*.js')
    .pipe($.uglify())
    .pipe(gulp.dest('./_build/'));
});

// minify CSS
gulp.task('minify-css', function() {
  gulp.src(['./styles/**/*.css', '!./styles/**/*.min.css'])
    .pipe($.rename({suffix: '.min'}))
    .pipe($.minifyCss({keepBreaks:true}))
    .pipe(gulp.dest('./styles/'))
    .pipe(gulp.dest('./_build/css/'));
});

// minify HTML
gulp.task('minify-html', function() {
  var opts = {
    comments: true,
    spare: true,
    conditionals: true
  };

  gulp.src('./*.html')
    .pipe($.minifyHtml(opts))
    .pipe(gulp.dest('./_build/'));
});

// copy fonts from a module outside of our project (like Bower)
gulp.task('fonts', function() {
  gulp.src('./fonts/**/*.{ttf,woff,eof,eot,svg}')
    .pipe($.changed('./_build/fonts'))
    .pipe(gulp.dest('./_build/fonts'));
});

// start webserver
gulp.task('server', function(done) {
  return browserSync({
    server: {
      baseDir: './'
    }
  }, done);
});

// start webserver from _build folder to check how it will look in production
gulp.task('server-build', function(done) {
  return browserSync({
    server: {
      baseDir: './_build/'
    }
  }, done);
});

// delete build folder
gulp.task('clean:build', function (cb) {
  del([
    './_build/'
    // if we don't want to clean any file we can use negate pattern
    //'!dist/mobile/deploy.json'
  ], cb);
});

// concat files
gulp.task('concat', function() {
  gulp.src('./js/*.js')
    .pipe($.concat('scripts.js'))
    .pipe(gulp.dest('./_build/'));
});

// SASS task, will run when any SCSS files change & BrowserSync
// will auto-update browsers
gulp.task('sass', function() {
  return gulp.src('styles/style.scss')
    .pipe($.sourcemaps.init())
    .pipe($.sass({
      style: 'expanded'
    }))
    .on('error', $.notify.onError({
      title: 'SASS Failed',
      message: 'Error(s) occurred during compile!'
    }))
    .pipe($.sourcemaps.write())
    .pipe(gulp.dest('styles'))
    .pipe(reload({
      stream: true
    }))
    .pipe($.notify({
      message: 'Styles task complete'
    }));
});

// SASS Build task
gulp.task('sass:build', function() {
  var s = $.size();

  return gulp.src('styles/style.scss')
    .pipe($.sass({
      style: 'compact'
    }))
    .pipe($.autoprefixer('last 3 version'))
    .pipe($.uncss({
      html: ['./index.html', './views/**/*.html', './components/**/*.html'],
      ignore: [
        '.index',
        '.slick',
        /\.owl+/,
        /\.owl-next/,
        /\.owl-prev/
      ]
    }))
    .pipe($.minifyCss({
      keepBreaks: true,
      aggressiveMerging: false,
      advanced: false
    }))
    .pipe($.rename({suffix: '.min'}))
    .pipe(gulp.dest('_build/css'))
    .pipe(s)
    .pipe($.notify({
      onLast: true,
      message: function() {
        return 'Total CSS size ' + s.prettySize;
      }
    }));
});

// BUGFIX: warning: possible EventEmitter memory leak detected. 11 listeners added.
require('events').EventEmitter.prototype._maxListeners = 100;

// index.html build
// script/css concatenation
gulp.task('usemin', function() {
  return gulp.src('./index.html')
    // add templates path
    .pipe($.htmlReplace({
      'templates': '<script type="text/javascript" src="js/templates.js"></script>'
    }))
    .pipe($.usemin({
      css: [$.minifyCss(), 'concat'],
      libs: [$.uglify()],
      nonangularlibs: [$.uglify()],
      angularlibs: [$.uglify()],
      appcomponents: [$.uglify()],
      mainapp: [$.uglify()]
    }))
    .pipe(gulp.dest('./_build/'));
});

// make templateCache from all HTML files
gulp.task('templates', function() {
  return gulp.src([
      './**/*.html',
      '!bower_components/**/*.*',
      '!node_modules/**/*.*',
      '!_build/**/*.*'
    ])
    .pipe($.minifyHtml())
    .pipe($.angularTemplatecache({
      module: 'boilerplate'
    }))
    .pipe(gulp.dest('_build/js'));
});

// reload all Browsers
gulp.task('bs-reload', function() {
  browserSync.reload();
});

// calculate build folder size
gulp.task('build:size', function() {
  var s = $.size();

  return gulp.src('./_build/**/*.*')
    .pipe(s)
    .pipe($.notify({
      onLast: true,
      message: function() {
        return 'Total build size ' + s.prettySize;
      }
    }));
});

// default task to be run with `gulp` command
// this default task will run BrowserSync & then use Gulp to watch files.
// when a file is changed, an event is emitted to BrowserSync with the filepath.
gulp.task('default', ['browser-sync', 'sass', 'minify-css'], function() {
  gulp.watch('styles/*.css', function(file) {
    if (file.type === "changed") {
      reload(file.path);
    }
  });
  gulp.watch(['*.html', 'views/*.html'], ['bs-reload']);
  gulp.watch(['app/*.js', 'components/**/*.js', 'js/*.js'], ['bs-reload']);
  gulp.watch('styles/**/*.scss', ['sass', 'minify-css']);
});

/**
 * build task:
 * 1. clean /_build folder
 * 2. compile SASS files, minify and uncss compiled css
 * 3. copy and minimize images
 * 4. minify and copy all HTML files into $templateCache
 * 5. build index.html
 * 6. minify and copy all JS files
 * 7. copy fonts
 * 8. show build folder size
 *
 */
gulp.task('build', function(callback) {
  runSequence(
    'clean:build',
    'sass:build',
    'images',
    'templates',
    'usemin',
    'fonts',
    'build:size',
    callback);
});
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp'),
    $ = require('gulp-load-plugins')(),
    browserSync = require('browser-sync'),
    reload = browserSync.reload,
    config = require('./config.json'),
    fs = require('fs'),
    runSequence = require('run-sequence');

// gulp.task('get', function() {
//     fs.readdir('./build', function(err, files) {
//         files.filter(function(file) { return file.substr(-5) === '.html'; })
//              .forEach(function(file) { console.log(file) });
//     });
// });

//gulp-svgmin
//gulp-svg2png
//gulp-data
//gulp-cssshrink

// gulp --type prod

var watch = false;
var copytext = config.copyright;

var onError = function(err) {
    $.util.beep();
    console.log(err);
};

var getStamp = function() {
    var myDate = new Date();

    var myYear = myDate.getFullYear().toString();
    var myMonth = ('0' + (myDate.getMonth() + 1)).slice(-2);
    var myDay = ('0' + myDate.getDate()).slice(-2);
    var mySeconds = myDate.getSeconds().toString();

    var myFullDate = myYear + myMonth + myDay + mySeconds;

    return myFullDate;
};

var patterns = [{
    pattern: /\.css/g,
    replacement: '\.css?' + getStamp()
}, {
    pattern: /\.js/g,
    replacement: '\.js?' + getStamp()
}, {
    pattern: /\.jpg/g,
    replacement: '\.jpg?' + getStamp()
}, {
    pattern: /\.ico/g,
    replacement: '\.ico?' + getStamp()
}, {
    pattern: /\.svg/g,
    replacement: '\.svg?' + getStamp()
}, {
    pattern: /\.png/g,
    replacement: '\.png?' + getStamp()
}, ];

gulp.task('browser-sync', function() {
    browserSync.init(null, {
        server: {
            baseDir: './build'
        }
    });
});

gulp.task('proxy', function() {
    gulp.src('/')
        .pipe($.run('./srvdir '+config.glob.proxy+':./build'));
});

// chmod
// gulp.task('chmod', function () {
//     return gulp.src('build/**/*')
//         .pipe($.chmod(644))
//         .pipe(gulp.dest('build'));
// });

gulp.task('sitemap', function () {
    gulp.src('build/**/*.html', {
        read: false
    })
    .pipe($.sitemap({
        siteUrl: config.glob.site
    }))
    .pipe(gulp.dest('build/'));
});

// Clean
gulp.task('clean', function() {
    return gulp.src(['./build/', '.sass-cache/', './.tmp', './jade/_includes/_html/'], {
            read: false
        })
        .pipe($.plumber({
            errorHandler: onError
        }))
        .pipe($.rimraf());
});

// Files
gulp.task('files', function() {
    return gulp.src(['./files/**/*', './files/**/.*', '!./files/**/.DS_Store'])
        .pipe($.plumber({
            errorHandler: onError
        }))
        .pipe(gulp.dest('build'))
        .pipe($.if(watch, reload({stream: true})));
});

// HTML
gulp.task('jade-pre', function() {
    var filterUsemin = $.filter('**/*.+(js|css)');
    return gulp.src(['jade/_includes/_*.jade'])
        .pipe($.plumber({
            errorHandler: onError
        }))
        .pipe($.jade({
            pretty: true,
        }))
        .pipe($.usemin({
            assetsDir: './',
            html: [$.if($.util.env.type === 'prod', $.htmlmin({
                collapseWhitespace: true,
                keepClosingSlash: true
            }))],
            css: [
                //($.if(env === 'production', $.uncss(config.uncss))),
                $.autoprefixer(config.autoprefixer),
                $.if($.util.env.type === 'prod', $.csso(), $.cssshrink())
            ],
            js: [
                $.if($.util.env.type === 'prod', $.uglify()),
                $.header(copytext)
            ]
        }))
        .pipe(filterUsemin)
        .pipe(gulp.dest('build'))
        .pipe(filterUsemin.restore())
        .pipe($.filter('**/*.+(html)'))
        .pipe(gulp.dest('jade/_includes/_html'));
});
gulp.task('jade-post', function() {
    return gulp.src(['jade/**/*.jade', '!jade/**/_*'])
        .pipe($.plumber({
            errorHandler: onError
        }))
        .pipe($.jade({
            pretty: true,
            basedir: './jade'
        }))
        .pipe($.usemin({
            assetsDir: './',
            html: [$.if($.util.env.type === 'prod', $.htmlmin({
                collapseWhitespace: true,
                keepClosingSlash: true
            }))],
            css: [
                // ($.if(env === 'production', $.uncss(config.uncss))),
                $.autoprefixer(config.autoprefixer),
                $.if($.util.env.type === 'prod', $.csso(), $.cssshrink())
            ],
            js: [
                $.if($.util.env.type === 'prod', $.uglify()),
                $.header(copytext)
            ]
        }))
        .pipe(gulp.dest('build'))
        .pipe($.if(watch, reload({stream: true})));
});

// CSS
gulp.task('sass', function() {
    return gulp.src('scss/**/*.scss')
        .pipe($.plumber({
            errorHandler: onError
        }))
        .pipe($.rubySass({
            loadPath: 'bower_components/foundation/scss',
            style: 'compact',
            compass: true
        }))
        .pipe(gulp.dest('.tmp/css'));
});

// Images
gulp.task('images', function() {
    return gulp.src(['images/**/*', '!images/base64/**/*', '!images/base64'])
        .pipe($.plumber({
            errorHandler: onError
        }))
        .pipe(gulp.dest('build/images'))
        .pipe($.filter('**/*.+(jpg|jpeg|png)'))
        .pipe($.webp())
        .pipe(gulp.dest('build/images'))
        .pipe($.if(watch, reload({stream: true})));
});
gulp.task('images-gen', function() {
    return gulp.src(['images/**/*'])
        .pipe($.plumber({
            errorHandler: onError
        }))
        .pipe($.imagemin({
            optimizationLevel: 5,
            progressive: true,
            interlaced: true
        }))
        .pipe(gulp.dest('images'));
});

gulp.task('cachebust', function () {
    return gulp.src('./build/**/*.+(html|css)')
        .pipe($.frep(patterns))
        .pipe(gulp.dest('build'))
});

// Tasks
gulp.task('jade', function(callback) {
    runSequence('jade-pre',
                'jade-post',
                ['sitemap','cachebust'],
                callback);
});

gulp.task('css', function(callback) {
    runSequence('sass',
                'jade',
                callback);
});

gulp.task('default', function(callback) {
    runSequence('clean',
                ['sass', 'images', 'files'],
                'jade',
                callback);
});

gulp.task('watch', ['default', 'browser-sync'], function() {
    gulp.watch(['scss/**/*.scss'], ['css']);
    gulp.watch(['jade/**/*.jade'], ['jade']);
    gulp.watch(['js/**/*.js'], ['jade']);
    gulp.watch(['images/**/*'], ['images']);
    watch = true;
});
<commit_msg>Clean gulpfile.js<commit_after>'use strict';

var gulp = require('gulp'),
    $ = require('gulp-load-plugins')(),
    browserSync = require('browser-sync'),
    reload = browserSync.reload,
    config = require('./config.json'),
    fs = require('fs'),
    runSequence = require('run-sequence');

// gulp.task('get', function() {
//     fs.readdir('./build', function(err, files) {
//         files.filter(function(file) { return file.substr(-5) === '.html'; })
//              .forEach(function(file) { console.log(file) });
//     });
// });

// gulp --type prod

var watch = false;
var copytext = config.copyright;

var onError = function(err) {
    $.util.beep();
    console.log(err);
};

var getStamp = function() {
    var myDate = new Date();

    var myYear = myDate.getFullYear().toString();
    var myMonth = ('0' + (myDate.getMonth() + 1)).slice(-2);
    var myDay = ('0' + myDate.getDate()).slice(-2);
    var mySeconds = myDate.getSeconds().toString();

    var myFullDate = myYear + myMonth + myDay + mySeconds;

    return myFullDate;
};

var patterns = [{
    pattern: /\.css/g,
    replacement: '\.css?' + getStamp()
}, {
    pattern: /\.js/g,
    replacement: '\.js?' + getStamp()
}, {
    pattern: /\.jpg/g,
    replacement: '\.jpg?' + getStamp()
}, {
    pattern: /\.ico/g,
    replacement: '\.ico?' + getStamp()
}, {
    pattern: /\.svg/g,
    replacement: '\.svg?' + getStamp()
}, {
    pattern: /\.png/g,
    replacement: '\.png?' + getStamp()
}, ];

gulp.task('browser-sync', function() {
    browserSync.init(null, {
        server: {
            baseDir: './build'
        }
    });
});

gulp.task('proxy', function() {
    gulp.src('/')
        .pipe($.run('./srvdir '+config.glob.proxy+':./build'));
});

gulp.task('chmod', function () {
    return gulp.src('build/**/*')
        .pipe($.chmod(644))
        .pipe(gulp.dest('build'));
});

gulp.task('sitemap', function () {
    gulp.src('build/**/*.html', {
        read: false
    })
    .pipe($.sitemap({
        siteUrl: config.glob.site
    }))
    .pipe(gulp.dest('build/'));
});

gulp.task('clean', function() {
    return gulp.src(['./build/', '.sass-cache/', './.tmp', './jade/_includes/_html/'], {
            read: false
        })
        .pipe($.plumber({
            errorHandler: onError
        }))
        .pipe($.rimraf());
});

gulp.task('files', function() {
    return gulp.src(['./files/**/*', './files/**/.*', '!./files/**/.DS_Store'])
        .pipe($.plumber({
            errorHandler: onError
        }))
        .pipe(gulp.dest('build'))
        .pipe($.if(watch, reload({stream: true})));
});

gulp.task('jade-pre', function() {
    var filterUsemin = $.filter('**/*.+(js|css)');
    return gulp.src(['jade/_includes/_*.jade'])
        .pipe($.plumber({
            errorHandler: onError
        }))
        .pipe($.jade({
            pretty: true,
        }))
        .pipe($.usemin({
            assetsDir: './',
            html: [$.if($.util.env.type === 'prod', $.htmlmin({
                collapseWhitespace: true,
                keepClosingSlash: true
            }))],
            css: [
                //($.if(env === 'production', $.uncss(config.uncss))),
                $.autoprefixer(config.autoprefixer),
                $.if($.util.env.type === 'prod', $.csso(), $.cssshrink())
            ],
            js: [
                $.if($.util.env.type === 'prod', $.uglify()),
                $.header(copytext)
            ]
        }))
        .pipe(filterUsemin)
        .pipe(gulp.dest('build'))
        .pipe(filterUsemin.restore())
        .pipe($.filter('**/*.+(html)'))
        .pipe(gulp.dest('jade/_includes/_html'));
});
gulp.task('jade-post', function() {
    return gulp.src(['jade/**/*.jade', '!jade/**/_*'])
        .pipe($.plumber({
            errorHandler: onError
        }))
        .pipe($.jade({
            pretty: true,
            basedir: './jade'
        }))
        .pipe($.usemin({
            assetsDir: './',
            html: [$.if($.util.env.type === 'prod', $.htmlmin({
                collapseWhitespace: true,
                keepClosingSlash: true
            }))],
            css: [
                // ($.if(env === 'production', $.uncss(config.uncss))),
                $.autoprefixer(config.autoprefixer),
                $.if($.util.env.type === 'prod', $.csso(), $.cssshrink())
            ],
            js: [
                $.if($.util.env.type === 'prod', $.uglify()),
                $.header(copytext)
            ]
        }))
        .pipe(gulp.dest('build'))
        .pipe($.if(watch, reload({stream: true})));
});

gulp.task('sass', function() {
    return gulp.src('scss/**/*.scss')
        .pipe($.plumber({
            errorHandler: onError
        }))
        .pipe($.rubySass({
            loadPath: 'bower_components/foundation/scss',
            style: 'compact',
            compass: true
        }))
        .pipe(gulp.dest('.tmp/css'));
});

gulp.task('images', function() {
    return gulp.src(['images/**/*', '!images/base64/**/*', '!images/base64'])
        .pipe($.plumber({
            errorHandler: onError
        }))
        .pipe(gulp.dest('build/images'))
        .pipe($.filter('**/*.+(jpg|jpeg|png)'))
        .pipe($.webp())
        .pipe(gulp.dest('build/images'))
        .pipe($.if(watch, reload({stream: true})));
});
gulp.task('images-gen', function() {
    return gulp.src(['images/**/*'])
        .pipe($.plumber({
            errorHandler: onError
        }))
        .pipe($.imagemin({
            optimizationLevel: 5,
            progressive: true,
            interlaced: true
        }))
        .pipe(gulp.dest('images'));
});

gulp.task('cachebust', function () {
    return gulp.src('./build/**/*.+(html|css)')
        .pipe($.frep(patterns))
        .pipe(gulp.dest('build'))
});

gulp.task('jade', function(callback) {
    runSequence('jade-pre',
                'jade-post',
                ['sitemap','cachebust'],
                callback);
});

gulp.task('css', function(callback) {
    runSequence('sass',
                'jade',
                callback);
});

gulp.task('default', function(callback) {
    runSequence('clean',
                ['sass', 'images', 'files'],
                'jade',
                callback);
});

gulp.task('watch', ['default', 'browser-sync'], function() {
    gulp.watch(['scss/**/*.scss'], ['css']);
    gulp.watch(['jade/**/*.jade'], ['jade']);
    gulp.watch(['js/**/*.js'], ['jade']);
    gulp.watch(['images/**/*'], ['images']);
    watch = true;
});
<|endoftext|>


<commit_before>'use strict';

const srcPath = './src/';

const gulp = require('gulp');
const exec = require('child_process').exec;
const runSequence = require('run-sequence');

function execNode(command) {
  exec(`node ${command}`, function (err, stdout, stderr) {
    if (stdout) {
      console.log(stdout);
    }

    if (stderr) {
      console.log(stderr);
    }
  });
}

gulp.task('build_theme', function () {
  execNode(`${srcPath}build.js`);
});

gulp.task('build_icons', function () {
  execNode(`${srcPath}icons.js`);
});

gulp.task('build', function (callback) {
  runSequence('build_theme', 'build_icons', callback);
});

gulp.task('watch', function () {
  gulp.watch(`${srcPath}**/*.js`, ['build']);
});

gulp.task('default', function (callback) {
  runSequence('build', 'watch', callback);
});
<commit_msg>Implemented more refined gulp.watch logic<commit_after>'use strict';

const srcPath = './src/';

const gulp = require('gulp');
const exec = require('child_process').exec;
const runSequence = require('run-sequence');

function execNode(command) {
  exec(`node ${command}`, function (err, stdout, stderr) {
    if (stdout) {
      console.log(stdout);
    }

    if (stderr) {
      console.log(stderr);
    }
  });
}

gulp.task('build_theme', function () {
  execNode(`${srcPath}build.js`);
});

gulp.task('build_icons', function () {
  execNode(`${srcPath}icons.js`);
});

gulp.task('build', function (callback) {
  runSequence('build_theme', 'build_icons', callback);
});

gulp.task('watch', function () {
  var themeFiles = [
    `${srcPath}build.js`,
    `${srcPath}components.js`,
    `${srcPath}components/*.js`,
    `${srcPath}options.js`,
    `${srcPath}palette.js`,
    `${srcPath}paths.js`,
    `${srcPath}scheme.js`,
    `${srcPath}sublime-options.js`,
    `${srcPath}tinycolor.js`,
    `${srcPath}utils.js`,
    `${srcPath}widget.js`,
  ];

  var iconFiles = [
    `${srcPath}icons.js`,
    `${srcPath}icons/*.json`,
    `${srcPath}utils.js`,
  ];

  gulp.watch(themeFiles, ['build_theme']);
  gulp.watch(iconFiles, ['build_icons']);
});

gulp.task('default', function (callback) {
  runSequence('build', 'watch', callback);
});
<|endoftext|>


<commit_before>var gulp        = require('gulp');
var browserSync = require('browser-sync');
var sass        = require('gulp-sass');
var prefix      = require('gulp-autoprefixer');
var merge       = require('merge-stream');
var imagemin    = require('gulp-imagemin');
var ghPages     = require('gulp-gh-pages');

// Start Static Server with browserSync
gulp.task('server', ['sass'], function() {
    browserSync({
        server: {
            baseDir: "dist/"
        }
    });
});

// Watch SCSS files for changes, recompile, compress, autoprefixed
gulp.task('sass', function () {
    return gulp.src('./_sass/main.scss')
        .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
        .pipe(prefix(['last 2 versions'], { cascade: true }))
        .pipe(gulp.dest('./assets/css'))
        .pipe(browserSync.reload({stream:true}));
});

// Watch SCSS & HTML files, run reload BrowserSync
gulp.task('watch', function () {
    gulp.watch('./_sass/**/*.scss', ['sass']);
    gulp.watch("./*.html").on('change', browserSync.reload);
});

// Task to build to dist
gulp.task('build', () => {
    const task = () => {
        let markup =  gulp.src('*.html')
    		.pipe(gulp.dest('dist/'));

        let styles = gulp.src('assets/css/main.css')
            .pipe(gulp.dest('dist/css/'));

        let images =  gulp.src('assets/images/**/')
    	    .pipe(imagemin())
    		.pipe(gulp.dest('dist/images/'));

        return merge(markup ,styles, images);
    }

    task();
});

// Deploy build dist to branch gh-pages
gulp.task('deploy', function() {
    return gulp.src('./dist/**/*')
        .pipe(ghPages({
            force: true
        }));
});

// Default task, running just `gulp`
gulp.task('default', ['server', 'watch']);
<commit_msg>update tasks<commit_after>var gulp = require('gulp');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
var merge = require('merge-stream');
var imagemin = require('gulp-imagemin');
var ghPages = require('gulp-gh-pages');

// Start Static Server with browserSync
gulp.task('server', ['sass'], function() {
    browserSync({
        server: {
            baseDir: "dist/"
        }
    });
});

// Watch SCSS files for changes, recompile, compress, autoprefixed
gulp.task('sass', function() {
    return gulp.src('./_sass/main.scss')
        .pipe(sass({
            outputStyle: 'compressed'
        }).on('error', sass.logError))
        .pipe(prefix(['last 2 versions'], {
            cascade: true
        }))
        .pipe(gulp.dest('./assets/css'))
        .pipe(browserSync.reload({
            stream: true
        }));
});

// Watch SCSS & HTML files, run reload BrowserSync
gulp.task('watch', function() {
    gulp.watch('./_sass/**/*.scss', ['sass']);
    gulp.watch("./*.html").on('change', browserSync.reload);
});

// Task to build to dist
gulp.task('build', () => {
    const task = () => {
        let markup = gulp.src('*.html')
            .pipe(gulp.dest('dist/'));

        let styles = gulp.src('assets/css/main.css')
            .pipe(gulp.dest('dist/css/'));

        let images = gulp.src('assets/images/**/')
            .pipe(imagemin())
            .pipe(gulp.dest('dist/images/'));

        return merge(markup, styles, images);
    }

    task();
});

// Deploy build dist to branch gh-pages
gulp.task('gh-pages', function() {
    return gulp.src('./dist/**/*')
        .pipe(ghPages({
            force: true
        }));
});

// Deploy build dist to branch gh-pages
gulp.task('deploy', ['build', 'gh-pages']);

// Default task, running just `gulp`
gulp.task('default', ['server', 'watch']);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var del = require('del');
var less = require('gulp-less');

var paths = {
  markup: 'frontend/index.html',
  less: 'frontend/style/*.less',
  dest: 'resources/public'
};

gulp.task('clean', function(cb) {
  del(['resources'], cb);
});

gulp.task('markup', function() {
  return gulp.src(paths.markup)
  .pipe(gulp.dest(paths.dest));
});

gulp.task('less', function () {
  gulp.src(paths.less)
  .pipe(less())
  .pipe(gulp.dest(paths.dest));
});

gulp.task('watch', ['markup', 'less'], function() {
  gulp.watch(paths.markup, ['markup']);
  gulp.watch(paths.less, ['less']);
});

gulp.task('default', ['markup', 'less']);
<commit_msg>Added concat of scripts to gulp tasks.<commit_after>var gulp = require('gulp');
var del = require('del');
var concat = require('gulp-concat');
var less = require('gulp-less');

var paths = {
  markup: 'frontend/index.html',
  less: 'frontend/style/*.less',
  scripts: ['bower_components/react/react.min.js'],
  dest: 'resources/public'
};

gulp.task('clean', function(cb) {
  del(['resources'], cb);
});

gulp.task('markup', function() {
  return gulp.src(paths.markup)
  .pipe(gulp.dest(paths.dest));
});

gulp.task('less', function () {
  gulp.src(paths.less)
  .pipe(less())
  .pipe(gulp.dest(paths.dest));
});

gulp.task('scripts', function () {
  return gulp.src(paths.scripts)
    .pipe(concat('all.min.js'))
    .pipe(gulp.dest(paths.dest));
});

gulp.task('watch', ['markup', 'less', 'scripts'], function() {
  gulp.watch(paths.markup, ['markup']);
  gulp.watch(paths.less, ['less']);
  gulp.watch(paths.scripts, ['scripts'])
});

gulp.task('default', ['markup', 'less', 'scripts']);
<|endoftext|>


<commit_before> /*
 * sublimetext-gulpfile.js
 * https://github.com/idleberg/sublimetext-gulpfile.js
 *
 * Copyright (c) 2014-2016 Jan T. Sott
 * Licensed under the MIT license.
 */

// Dependencies
var gulp = require('gulp'),
    debug = require('gulp-debug'),
    jsonlint = require('gulp-json-lint');
    ymlVal = require('gulp-yaml-validate');
    xmlVal = require('gulp-xml-validator');

// Supported files
var jsonFiles = [
    '!node_modules/**/*',
    '**/*.JSON-sublime-syntax',
    '**/*.JSON-tmLanguage',
    '**/*.JSON-tmTheme',
    '**/*.sublime-build',
    '**/*.sublime-commands',
    '**/*.sublime-completions',
    '**/*.sublime-keymap',
    '**/*.sublime-macro',
    '**/*.sublime-menu',
    '**/*.sublime-settings',
    '**/*.sublime-theme',
    'messages.json'
];

var xmlFiles = [
    '!node_modules/**/*',
    '**/*.plist',
    '**/*.PLIST-sublime-syntax',
    '**/*.PLIST-tmLanguage',
    '**/*.PLIST-tmTheme',
    '**/*.sublime-snippet',
    '**/*.tmCommand',
    '**/*.tmLanguage',
    '**/*.tmPreferences',
    '**/*.tmSnippet',
    '**/*.tmTheme',
    '**/*.xml',
    '*.bbcolors',
    '*.dvtcolortheme',
    '*.icls',
    '*.itermcolors',
    '*.terminal'
];

var ymlFiles = [
    '!node_modules/**/*',
    '**/*.sublime-syntax',
    '**/*.YAML-tmLanguage',
    '**/*.YAML-tmTheme'
];

// Available tasks
gulp.task('lint', ['lint:json', 'lint:xml', 'lint:yml']);

// Lint JSON
gulp.task('lint:json', function(){
  return gulp.src(jsonFiles)
    .pipe(debug({title: 'lint:json'}))
    .pipe(jsonlint())
});

// Validate XML
gulp.task('lint:xml', function() {
  return gulp.src(xmlFiles)
    .pipe(debug({title: 'lint:xml'}))
    .pipe(xmlVal());
});

// Validate YAML
gulp.task('lint:yml', function() {
  return gulp.src(ymlFiles)
    .pipe(debug({title: 'lint:yml'}))
    .pipe(ymlVal({ safe: true }));
});
<commit_msg>delete gulpfile<commit_after><|endoftext|>


<commit_before>const gulp = require('gulp');
const packager = require('electron-packager');
const _ = require('lodash');

const path = require('path');
const fs = require('fs');

function create_library_directory(buildPath) {
	var appPath = path.join('.', buildPath, 'library');
	fs.mkdirSync(appPath);
}

var BASE_OPTION = {
	dir: '.',
	overwrite: true,
	arch: 'x64',
	//electronVersion: '1.7.6',
	ignore: '(icons|releases|.idea.*|README\.md|\.DS_Store|env|gulpfile\.js|webpack\.config\.js|\.gitignore|\.gjslintrc)',
	asar: true,
	prune: true,
	extraResource: './dist/icon.png'
};

gulp.task('electron-darwin', function(done) {
	var c = _.defaults(_.clone(BASE_OPTION), {
		out: 'releases/darwin/',
		platform: 'darwin',
		icon: './icons/pilemd.icns',
		sign: process.env['PM_OSX_SIGN'],
		'helper-buldle-id': 'md.pile.helper',
		'app-bundle-id': 'md.pile'
	});

	packager(c).then((appPaths) => {
		create_library_directory(appPaths[0]);
		done();
	}).catch((err) => {
		console.log(err);
	});
});

gulp.task('electron-linux', function(done) {
	var c = _.defaults(_.clone(BASE_OPTION), {
		out: './releases/linux/',
		platform: 'linux'
	});

	packager(c).then((appPaths) => {
		create_library_directory(appPaths[0]);
		done();
	}).catch((err) => {
		console.log(err);
	});
});

gulp.task('electron-windows', function(done) {
	var c = _.defaults(_.clone(BASE_OPTION), {
		out: './releases/windows/',
		platform: 'win32',
		icon: './icons/pilemd.ico'
	});
	// c['arch'] = 'ia32';
	packager(c).then((err, appPaths) => {
		create_library_directory(appPaths[0]);
		done();
	}).catch((err) => {
		console.log(err);
	});
});
<commit_msg>build windows fix<commit_after>const gulp = require('gulp');
const packager = require('electron-packager');
const _ = require('lodash');

const path = require('path');
const fs = require('fs');

function create_library_directory(buildPath) {
	var appPath = path.join('.', buildPath, 'library');
	fs.mkdirSync(appPath);
}

var BASE_OPTION = {
	dir: '.',
	overwrite: true,
	arch: 'x64',
	//electronVersion: '1.7.6',
	ignore: '(icons|releases|.idea.*|README\.md|\.DS_Store|env|gulpfile\.js|webpack\.config\.js|\.gitignore|\.gjslintrc)',
	asar: true,
	prune: true,
	extraResource: './dist/icon.png'
};

gulp.task('electron-darwin', function(done) {
	var c = _.defaults(_.clone(BASE_OPTION), {
		out: 'releases/darwin/',
		platform: 'darwin',
		icon: './icons/pilemd.icns',
		sign: process.env['PM_OSX_SIGN'],
		'helper-buldle-id': 'md.pile.helper',
		'app-bundle-id': 'md.pile'
	});

	packager(c).then((appPaths) => {
		create_library_directory(appPaths[0]);
		done();
	}).catch((err) => {
		console.log(err);
	});
});

gulp.task('electron-linux', function(done) {
	var c = _.defaults(_.clone(BASE_OPTION), {
		out: './releases/linux/',
		platform: 'linux'
	});

	packager(c).then((appPaths) => {
		create_library_directory(appPaths[0]);
		done();
	}).catch((err) => {
		console.log(err);
	});
});

gulp.task('electron-windows', function(done) {
	var c = _.defaults(_.clone(BASE_OPTION), {
		out: './releases/windows/',
		platform: 'win32',
		icon: './icons/pilemd.ico'
	});
	// c['arch'] = 'ia32';
	packager(c).then((appPaths) => {
		create_library_directory(appPaths[0]);
		done();
	}).catch((err) => {
		console.log(err);
	});
});
<|endoftext|>


<commit_before>'use strict';
var path = require("path");
var gulp = require("gulp");
var runSequence = require('run-sequence');
var shell = require('gulp-shell');
var connect = require('gulp-connect');
var open = require('open');

gulp.task('connect', function() {
  console.log('Starting BabylonHX');
  connect.server({
    root: ['bin_lime/html5/bin/'],
    port: 3000,
    livereload: true
  });
  open('http://localhost:3000');
});

gulp.task('restart', function() {
  console.log('reload BabylonHX');
  connect.reload();
});

var paths = {
    main: ["**/**.hx"]
};

gulp.task('default', function (callback) {
    gulp.start('connect');
    gulp.start('watch');

});

gulp.task('watch', function (callback) {
    gulp.watch(paths.main, ['buildpureJS', 'buildlime', 'restart']);
});

gulp.task('test', shell.task([
    'haxe compile.hxml'
]));

gulp.task('buildlime', shell.task([
    'lime build html5 -Dwebgl'
]));

gulp.task('buildpureJS', shell.task([
    'haxe build_js.hxml'
]));

gulp.task('install_dep', shell.task([
    'haxelib setup',
    'haxelib -notimeout install lime',
    'haxelib -notimeout install dox',
    'haxelib -notimeout install openfl',
    'haxelib -notimeout install swf',
    'haxelib -notimeout install svg',
    'haxelib -notimeout install actuate',
    'haxelib -notimeout git cannonhx https://github.com/vujadin/cannon.hx.git',
    'haxelib -notimeout git babylonhxext https://github.com/vujadin/BabylonHx_Extensions.git',
    'haxelib -notimeout git catamaranhx https://github.com/catamaranHX/catamaranHX_lib.git',
    'haxelib -notimeout git snow https://github.com/underscorediscovery/snow.git',
    'haxelib -notimeout git oimohx https://github.com/babylonhx/OimoHx.git',
    'haxelib -notimeout git msgpack https://github.com/aaulia/msgpack-haxe.git',
    'haxelib -notimeout git babylonhx https://github.com/babylonhx/BabylonHx_2.0.git'
]));

gulp.task('dox', shell.task([
    'lime build html5 -xml',
    'haxelib run dox -i bin_lime/html5/ -o api/'
]));<commit_msg>dependency changes<commit_after>'use strict';
var path = require("path");
var gulp = require("gulp");
var runSequence = require('run-sequence');
var shell = require('gulp-shell');
var connect = require('gulp-connect');
var open = require('open');

gulp.task('connect', function() {
  console.log('Starting BabylonHX');
  connect.server({
    root: ['bin_lime/html5/bin/'],
    port: 3000,
    livereload: true
  });
  open('http://localhost:3000');
});

gulp.task('restart', function() {
  console.log('reload BabylonHX');
  connect.reload();
});

var paths = {
    main: ["**/**.hx"]
};

gulp.task('default', function (callback) {
    gulp.start('connect');
    gulp.start('watch');

});

gulp.task('watch', function (callback) {
    gulp.watch(paths.main, ['buildpureJS', 'buildlime', 'restart']);
});

gulp.task('test', shell.task([
    'haxe compile.hxml'
]));

gulp.task('buildlime', shell.task([
    'lime build html5 -Dwebgl'
]));

gulp.task('buildpureJS', shell.task([
    'haxe build_js.hxml'
]));

gulp.task('install_dep', shell.task([
    'sudo haxelib -notimeout install lime',
    'sudo haxelib -notimeout install dox',
    'sudo haxelib -notimeout install openfl',
    'sudo haxelib -notimeout install swf',
    'sudo haxelib -notimeout install svg',
    'sudo haxelib -notimeout install actuate',
    'sudo haxelib -notimeout install flixel',
    'sudo haxelib -notimeout install kha',
    'sudo haxelib -notimeout git cannonhx https://github.com/vujadin/cannon.hx.git',
    'sudo haxelib -notimeout git babylonhxext https://github.com/vujadin/BabylonHx_Extensions.git',
    'sudo haxelib -notimeout git catamaranhx https://github.com/catamaranHX/catamaranHX_lib.git',
    'sudo haxelib -notimeout git snow https://github.com/underscorediscovery/snow.git',
    'sudo haxelib -notimeout git oimohx https://github.com/babylonhx/OimoHx.git',
    'sudo haxelib -notimeout git msgpack https://github.com/aaulia/msgpack-haxe.git',
    'sudo haxelib -notimeout git babylonhx https://github.com/babylonhx/BabylonHx_2.0.git'
]));

gulp.task('dox', shell.task([
    'lime build html5 -xml',
    'haxelib run dox -i bin_lime/html5/ -o api/'
]));<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var filesize = require('gulp-filesize');
var minifyCss = require('gulp-minify-css');
var plumber = require('gulp-plumber');

gulp.task('sass', function () {
    gulp.src('./src/WebRobot/FreelanceBundle/Resources/assets/sass/**/*.scss')
        .pipe(plumber())
        .pipe(filesize())
        .pipe(sass().on('error', sass.logError))
        .pipe(autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false
        }))
        .pipe(minifyCss({compatibility: 'ie8'}))
        .pipe(gulp.dest('./src/WebRobot/FreelanceBundle/Resources/public/css'))
        .pipe(filesize());
});

gulp.task('sass:watch', function () {
    gulp.watch('./src/WebRobot/FreelanceBundle/Resources/assets/sass/**/*.scss', ['sass']);
});<commit_msg>add gulp default task<commit_after>'use strict';

var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var filesize = require('gulp-filesize');
var minifyCss = require('gulp-minify-css');
var plumber = require('gulp-plumber');

gulp.task('sass', function () {
    gulp.src('./src/WebRobot/FreelanceBundle/Resources/assets/sass/**/*.scss')
        .pipe(plumber())
        .pipe(filesize())
        .pipe(sass().on('error', sass.logError))
        .pipe(autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false
        }))
        .pipe(minifyCss({compatibility: 'ie8'}))
        .pipe(gulp.dest('./src/WebRobot/FreelanceBundle/Resources/public/css'))
        .pipe(filesize());
});

gulp.task('sass:watch', function () {
    gulp.watch('./src/WebRobot/FreelanceBundle/Resources/assets/sass/**/*.scss', ['sass']);
});

gulp.task('default', ['sass']);<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp'),
		sass = require('gulp-sass'),
		sourcemaps = require('gulp-sourcemaps'),
		jshint = require('gulp-jshint'),
		wiredep = require('wiredep').stream,
		useref = require('gulp-useref'),
		del = require('del'),
		gulpif = require('gulp-if'),
		uglify = require('gulp-uglify'),
		minifyCss = require('gulp-minify-css'),
		browserSync = require('browser-sync')
;

// SCSS task
gulp.task('sass', function() {

	return gulp.src('app/scss/app.scss')
		.pipe(sourcemaps.init())
		.pipe(sass().on('error', sass.logError))
		.pipe(sourcemaps.write())
		.pipe(gulp.dest('app/css'))
		.pipe(browserSync.stream())
		;

});

// JSHint task
gulp.task('lint', function() {

	return gulp.src('app/js/*.js')
		.pipe(jshint())
		.pipe(jshint.reporter('jshint-stylish'))
		;

});

// Reload browser after lint task complete
gulp.task('js-watch', ['lint'], browserSync.reload);

// Bower task
gulp.task('bower',function() {

	return gulp.src('app/*.html')
		.pipe(wiredep({
			exclude: ['app/bower_components/modernizr/dist/modernizr-build.js']
		}))
		.pipe(gulp.dest('app'))
		;

});

// Useref task
gulp.task('useref', ['del'], function() {

	var assets = useref.assets();

	return gulp.src('app/*.html')
		.pipe(assets)
		.pipe(gulpif('*.js', uglify()))
		.pipe(gulpif('*.css', minifyCss()))
		.pipe(assets.restore())
		.pipe(useref())
		.pipe(gulp.dest('dist'))
		;

});

// Delete files task
gulp.task('del', function() {

	return del('dist/**');

});

// BrowserSync
gulp.task('serve', function() {
	browserSync.init({
		server: 'app'
	});

	gulp.watch('app/scss/**/*.scss', ['sass']);
	gulp.watch('app/*.html').on('change', browserSync.reload);
	gulp.watch('app/js/*.js', ['js-watch']);
});

// Build task
gulp.task('build', ['useref']);

// Default task
gulp.task('default', ['serve']);<commit_msg>create compress images task<commit_after>'use strict';

var gulp = require('gulp'),
		sass = require('gulp-sass'),
		sourcemaps = require('gulp-sourcemaps'),
		jshint = require('gulp-jshint'),
		wiredep = require('wiredep').stream,
		useref = require('gulp-useref'),
		del = require('del'),
		gulpif = require('gulp-if'),
		uglify = require('gulp-uglify'),
		minifyCss = require('gulp-minify-css'),
		browserSync = require('browser-sync'),
		imagemin = require('gulp-imagemin'),
		pngquant = require('imagemin-pngquant')
;

// SCSS task
gulp.task('sass', function() {

	return gulp.src('app/scss/app.scss')
		.pipe(sourcemaps.init())
		.pipe(sass().on('error', sass.logError))
		.pipe(sourcemaps.write())
		.pipe(gulp.dest('app/css'))
		.pipe(browserSync.stream())
		;

});

// JSHint task
gulp.task('lint', function() {

	return gulp.src('app/js/*.js')
		.pipe(jshint())
		.pipe(jshint.reporter('jshint-stylish'))
		;

});

// Reload browser after lint task complete
gulp.task('js-watch', ['lint'], browserSync.reload);

// Image Task
gulp.task('imagemin', function() {

	return gulp.src('app/images/*')
		.pipe(imagemin({
			progressive: true,
			svgoPlugins: [{removeViewBox: false}],
			use: [pngquant()]
		}))
		.pipe(gulp.dest('dist/images'))
		;

});

// Bower task
gulp.task('bower',function() {

	return gulp.src('app/*.html')
		.pipe(wiredep({
			exclude: ['app/bower_components/modernizr/dist/modernizr-build.js']
		}))
		.pipe(gulp.dest('app'))
		;

});

// Useref task
gulp.task('useref', ['del'], function() {

	var assets = useref.assets();

	return gulp.src('app/*.html')
		.pipe(assets)
		.pipe(gulpif('*.js', uglify()))
		.pipe(gulpif('*.css', minifyCss()))
		.pipe(assets.restore())
		.pipe(useref())
		.pipe(gulp.dest('dist'))
		;

});

// Delete files task
gulp.task('del', function() {

	return del('dist/**');

});

// BrowserSync
gulp.task('serve', function() {
	browserSync.init({
		server: 'app'
	});

	gulp.watch('app/scss/**/*.scss', ['sass']);
	gulp.watch('app/*.html').on('change', browserSync.reload);
	gulp.watch('app/js/*.js', ['js-watch']);
});

// Build task
gulp.task('build', ['useref']);

// Default task
gulp.task('default', ['serve']);<|endoftext|>


<commit_before>var gulp = require('gulp');
var sass = require('gulp-sass');
var plumber = require('gulp-plumber');
var source = require('vinyl-source-stream');
var sourcemaps = require('gulp-sourcemaps');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var babel = require('gulp-babel');
var glob = require('glob');
var concat = require('gulp-concat');
var eventstream = require('event-stream');

/**
 * Compile plugin SASS
 */
gulp.task('plugins-sass', function() {
    gulp.src('./plugins/*/client/sass/**/*.scss')
        .pipe(plumber())
        .pipe(concat('plugins.css'))
        .pipe(sass({
            includePaths: [
               './node_modules/sass-material-colors/sass/'
            ]
        }))
        .pipe(gulp.dest('./public/css/'));
});

/**
 * Compile plugin JS
 */
gulp.task('plugins-js', function() {
    glob('./plugins/*/client/js/client.js', function(err, files) {
        if(err) {
            done(err);
        }

        return browserify(files)
            .bundle()
            .pipe(plumber())
            .pipe(source('client.js'))
            .pipe(buffer())
            .pipe(sourcemaps.init({loadMaps: true}))
                .pipe(babel({
                    presets: [ 'es2015' ]
                }))
            .pipe(concat('plugins.js'))
            .pipe(gulp.dest('./public/js/'));
    });

});

/**
 * Watch plugin code
 */
gulp.task('plugins-watch', function() {
    gulp.watch('./plugins/**/*.js', [ 'plugins-js' ]);
    gulp.watch('./src/common/**/*.js', [ 'plugins-js' ]);
    gulp.watch('./plugins/**/*.scss', [ 'plugins-sass' ]);
});

/**
 * Compile native SASS
 */
gulp.task('sass', function() {
    gulp.src('./src/client/sass/client.scss')
        .pipe(plumber())
        .pipe(sass({
            includePaths: [
                './node_modules/sass-material-colors/sass/'
            ]
        }))
        .pipe(gulp.dest('./public/css'));
});

/**
 * Compile native JS
 */
gulp.task('js', function() {
    return browserify({
        entries: './src/client/js/client.js'
    })
    .on('error', function(err) {
        console.log(err);
        this.emit('end');
    })
    .bundle()
    .pipe(source('client.js'))
    .pipe(buffer())
    .pipe(babel({
        presets: [ 'es2015' ]
    }))
    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest('./public/js/'));
});

/**
 * Watch native code
 */
gulp.task('watch', function() {
    gulp.watch('./src/client/js/**/*.js', [ 'js' ]);
    gulp.watch('./src/common/**/*.js', [ 'js' ]);
    gulp.watch('./src/client/sass/**/*.scss', [ 'sass' ]);
});

// ----------
// Default tasks
// ----------
gulp.task('default', [
    'plugins-sass',
    'plugins-js',
    'plugins-watch',
    'sass',
    'js',
    'watch'
]);
<commit_msg>added gulp exception catch<commit_after>var gulp = require('gulp');
var sass = require('gulp-sass');
var plumber = require('gulp-plumber');
var source = require('vinyl-source-stream');
var sourcemaps = require('gulp-sourcemaps');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var babel = require('gulp-babel');
var glob = require('glob');
var concat = require('gulp-concat');
var eventstream = require('event-stream');

/**
 * Compile plugin SASS
 */
gulp.task('plugins-sass', function() {
    gulp.src('./plugins/*/client/sass/**/*.scss')
        .pipe(plumber())
        .pipe(concat('plugins.css'))
        .pipe(sass({
            includePaths: [
               './node_modules/sass-material-colors/sass/'
            ]
        }))
        .pipe(gulp.dest('./public/css/'));
});

/**
 * Compile plugin JS
 */
gulp.task('plugins-js', function() {
    glob('./plugins/*/client/js/client.js', function(err, files) {
        if(err) {
            done(err);
        }

        return browserify(files)
            .bundle()
            .on('error', function(err) {
                console.log(err.toString());
                this.emit('end');
            })
            .pipe(plumber())
            .pipe(source('client.js'))
            .pipe(buffer())
            .pipe(sourcemaps.init({loadMaps: true}))
                .pipe(babel({
                    presets: [ 'es2015' ]
                }))
            .pipe(concat('plugins.js'))
            .pipe(gulp.dest('./public/js/'));
    });

});

/**
 * Watch plugin code
 */
gulp.task('plugins-watch', function() {
    gulp.watch('./plugins/**/*.js', [ 'plugins-js' ]);
    gulp.watch('./src/common/**/*.js', [ 'plugins-js' ]);
    gulp.watch('./plugins/**/*.scss', [ 'plugins-sass' ]);
});

/**
 * Compile native SASS
 */
gulp.task('sass', function() {
    gulp.src('./src/client/sass/client.scss')
        .pipe(plumber())
        .pipe(sass({
            includePaths: [
                './node_modules/sass-material-colors/sass/'
            ]
        }))
        .pipe(gulp.dest('./public/css'));
});

/**
 * Compile native JS
 */
gulp.task('js', function() {
    return browserify({
        entries: './src/client/js/client.js'
    })
    .on('error', function(err) {
        console.log(err);
        this.emit('end');
    })
    .bundle()
    .pipe(source('client.js'))
    .pipe(buffer())
    .pipe(babel({
        presets: [ 'es2015' ]
    }))
    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest('./public/js/'));
});

/**
 * Watch native code
 */
gulp.task('watch', function() {
    gulp.watch('./src/client/js/**/*.js', [ 'js' ]);
    gulp.watch('./src/common/**/*.js', [ 'js' ]);
    gulp.watch('./src/client/sass/**/*.scss', [ 'sass' ]);
});

// ----------
// Default tasks
// ----------
gulp.task('default', [
    'plugins-sass',
    'plugins-js',
    'plugins-watch',
    'sass',
    'js',
    'watch'
]);
<|endoftext|>


<commit_before>var gulp         = require('gulp');
var gcoffee      = require('gulp-coffee');
var gconcat      = require('gulp-concat');
var gconnect     = require('gulp-connect');
var gif          = require('gulp-if');
var gjade        = require('gulp-jade');
var gjst         = require('gulp-jst-concat');
var gless        = require('gulp-less');
var gmaps        = require('gulp-sourcemaps');
var gmin         = require('gulp-minify-css');
var gpages       = require("gulp-gh-pages");
var grename      = require('gulp-rename');
var gdel         = require('del');
var guglify      = require('gulp-uglify');
var gutil        = require('gulp-util');

var paths = {
  scripts: [
              'bower_components/modernizr/modernizr.js',
              'bower_components/lodash/dist/lodash.js',
              'bower_components/jquery/dist/jquery.js',
              'bower_components/sifter/sifter.js',
              'bower_components/microplugin/src/microplugin.js',
              'bower_components/selectize/dist/js/selectize.js',
              'bower_components/backbone/backbone.js',
              'bower_components/backbone.marionette/lib/backbone.marionette.js',
              'src/scripts/extensions/*.coffee',
              'src/scripts/application.coffee',
              'src/scripts/models/model.coffee',
              'src/scripts/models/unit.coffee',
              'src/scripts/models/measurement.coffee',
              'src/scripts/models/calculation.coffee',
              'src/scripts/views/unit_view.coffee',
              'src/scripts/views/measurement/show.coffee',
              'src/scripts/views/measurement/edit.coffee',
              'src/scripts/views/calculation_view.coffee',
              'src/scripts/collections/*.coffee',
              'tmp/templates.js'
            ]
}

gulp.task('connect', function() {
  gconnect.server({
    root: 'build',
    livereload: true
  });
});

gulp.task('clean', function() {
  gdel(['build/**/*', 'dist/**/*'], function(){})
});

gulp.task('scripts', function() {
  gulp.src(paths.scripts)
      .pipe(gmaps.init())
      .pipe(gif(/[.]coffee$/, gcoffee({ bare: true }).on('error', function(err) {
            gutil.log(gutil.colors.red(err))
      })))
      .pipe(gconcat('application.js'))
      .pipe(gmaps.write())
      .pipe(gulp.dest('build/scripts'))
      .pipe(gconnect.reload());
});

// Precompile jade templates into a JST
gulp.task('templates', function(){
  gulp.src(['src/templates/**/*.jade'])
    .pipe(gjade().on('error', function (err) {
      gutil.log(gutil.colors.red(err))
    }))
    .pipe(gjst('templates.js', { renameKeys: ['^.*templates/(.*).html$', '$1'] }))
    .pipe(gulp.dest('tmp/'));
});

gulp.task('styles', function() {
  gulp.src(['src/styles/**/*.{css,less}'])
      .pipe(gmaps.init())
      .pipe(gless().on('error', function(err){
        gutil.log(gutil.colors.red(err.message))
      }))
      .pipe(gmaps.write())
      .pipe(gulp.dest('build/styles'))
      .pipe(gconnect.reload());
});

gulp.task('content', function() {
  gulp.src(['src/content/**/*.jade', '!src/content/layouts/**'])
      .pipe(gjade().on('error', function(err){
        gutil.log(gutil.colors.red(err))
      }))
      .pipe(gulp.dest('build'))
      .pipe(gconnect.reload());
});

gulp.task('build',['content','styles','templates','scripts']);

gulp.task('watch', function() {
  gulp.watch(['src/content/**'],['content']);
  gulp.watch(['src/styes/**'],['styles']);
  gulp.watch(['src/templates/**'],['templates'])
  gulp.watch(paths.scripts,['scripts']);
});

gulp.task('deploy', function () {
    gulp.src("dist/**/*")
        .pipe(gpages());
});
gulp.task('default',['connect','build','watch']);<commit_msg>Update compilation and deployment tasks.<commit_after>var gulp         = require('gulp');
var gcoffee      = require('gulp-coffee');
var gconcat      = require('gulp-concat');
var gconnect     = require('gulp-connect');
var gif          = require('gulp-if');
var gjade        = require('gulp-jade');
var gjst         = require('gulp-jst-concat');
var gless        = require('gulp-less');
var gmaps        = require('gulp-sourcemaps');
var gmin         = require('gulp-minify-css');
var gpages       = require("gulp-gh-pages");
var grename      = require('gulp-rename');
var gdel         = require('del');
var guglify      = require('gulp-uglify');
var gutil        = require('gulp-util');

var paths = {
  scripts: [
              'bower_components/modernizr/modernizr.js',
              'bower_components/lodash/dist/lodash.js',
              'bower_components/jquery/dist/jquery.js',
              'bower_components/sifter/sifter.js',
              'bower_components/microplugin/src/microplugin.js',
              'bower_components/selectize/dist/js/selectize.js',
              'bower_components/backbone/backbone.js',
              'bower_components/backbone.marionette/lib/backbone.marionette.js',
              'src/scripts/extensions/*.coffee',
              'src/scripts/application.coffee',
              'src/scripts/models/model.coffee',
              'src/scripts/models/unit.coffee',
              'src/scripts/models/measurement.coffee',
              'src/scripts/models/calculation.coffee',
              'src/scripts/views/unit_view.coffee',
              'src/scripts/views/measurement/show.coffee',
              'src/scripts/views/measurement/edit.coffee',
              'src/scripts/views/calculation_view.coffee',
              'src/scripts/collections/*.coffee',
              'tmp/templates.js'
            ]
}

gulp.task('connect', function() {
  gconnect.server({
    root: 'build',
    livereload: true
  });
});

gulp.task('clean', function() {
  gdel(['build/**/*', 'dist/**/*'], function(){})
});

gulp.task('build-scripts', function() {
  gulp.src(paths.scripts)
      .pipe(gmaps.init())
      .pipe(gif(/[.]coffee$/, gcoffee({ bare: true }).on('error', function(err) {
            gutil.log(gutil.colors.red(err))
      })))
      .pipe(gconcat('application.js'))
      .pipe(gmaps.write())
      .pipe(gulp.dest('build/scripts'))
      .pipe(gconnect.reload());
});

gulp.task('compile-scripts', function() {
  gulp.src(paths.scripts)
      .pipe(gif(/[.]coffee$/, gcoffee({ bare: true })))
      .pipe(gconcat('application.js'))
      .pipe(guglify())
      .pipe(gulp.dest('dist/scripts'))
});

// Precompile jade templates into a JST
gulp.task('templates', function(){
  gulp.src(['src/templates/**/*.jade'])
    .pipe(gjade().on('error', function (err) {
      gutil.log(gutil.colors.red(err))
    }))
    .pipe(gjst('templates.js', { renameKeys: ['^.*templates/(.*).html$', '$1'] }))
    .pipe(gulp.dest('tmp/'));
});

gulp.task('build-styles', function() {
  gulp.src(['src/styles/**/*.{css,less}'])
      .pipe(gmaps.init())
      .pipe(gless().on('error', function(err){
        gutil.log(gutil.colors.red(err.message))
      }))
      .pipe(gmaps.write())
      .pipe(gulp.dest('build/styles'))
      .pipe(gconnect.reload());
});

gulp.task('compile-styles', function() {
  gulp.src(['src/styles/**/*.{css,less}'])
      .pipe(gless())
      .pipe(gmin({keepSpecialComments: false}))
      .pipe(gulp.dest('dist/styles'))
});

gulp.task('build-content', function() {
  gulp.src(['src/content/**/*.jade', '!src/content/layouts/**'])
      .pipe(gjade().on('error', function(err){
        gutil.log(gutil.colors.red(err))
      }))
      .pipe(gulp.dest('build'))
      .pipe(gconnect.reload());
});

gulp.task('compile-content', function() {
  gulp.src(['src/content/**/*.jade', '!src/content/layouts/**'])
      .pipe(gjade())
      .pipe(gulp.dest('dist'))
});

gulp.task('build',['templates','build-content','build-styles','build-scripts']);
gulp.task('compile', ['templates','compile-content','compile-styles','compile-scripts']);

gulp.task('watch', function() {
  gulp.watch(['src/content/**'],['content']);
  gulp.watch(['src/styes/**'],['styles']);
  gulp.watch(['src/templates/**'],['templates'])
  gulp.watch(paths.scripts,['scripts']);
});

gulp.task('deploy', function () {
    gulp.src("dist/**/*")
        .pipe(gpages());
});

gulp.task('default',['connect','build','watch']);<|endoftext|>


<commit_before>const gulp = require('gulp'),
	gutil = require('gulp-util'),
	connect = require('gulp-connect'),
	orderBy = require('lodash.orderby'),
	merge = require('lodash.merge'),
	moment = require('moment-timezone'),
	pkg = require('./package.json'),
	rimraf = require('rimraf'),
	mustache = require('mustache'),
	parallelize = require("concurrent-transform");

let PUG_LOCALS = {
	LASTMOD: moment.tz(pkg.config.loc).format(),
	DOMAIN: (process.env.NODE_ENV == 'production') ? pkg.config.domain : 'http://localhost:3303/',
	VERSION: pkg.version
};

let watching = false;

Object.defineProperty(pkg, 'fresh', {
	get: () => ((fresh) => {
		fresh.employment = (emp => {
			emp.history = orderBy(emp.history, v => {
				return new Date(v.start).getUTCMilliseconds();
			});

			emp.history.forEach(item => {
				item.keywords.sort();
			});

			return emp;
		})(fresh.employment);

		return fresh;
	})(((fresh) => {
		return JSON.parse(mustache.render(fresh, PUG_LOCALS));
	})(JSON.stringify(require('./src/app/meta/fresh.json'))))
});

function plumb() {
	return require('gulp-plumber')({errorHandler: require('gulp-notify').onError("Error: <%= error.message %>")})
}

function webpackCallback(err, stats) {
	console.log(err, stats);
	if (err) throw require('gulp-notify')()(err);

	gutil.log("[webpack]", stats.toString({
		colours: true,
		progress: true
	}));
}

gulp.task('default', ['images', 'js', 'scss', 'pug', 'fonts', 'images']);

gulp.task('prewatch', () => {
	watching = true;
});

gulp.task('watch', ['prewatch', 'default'], () => {
	gulp.watch('./src/app/**/*.pug', ['pug']);
	gulp.watch('./src/assets/**/*.scss', ['scss']);
	gulp.watch('./src/assets/img/**/*', ['images']);

	require('webpack')(Object.assign({watch: true}, require('./webpack.config.js')), (err, stats) => {
		webpackCallback(err, stats);
	});
});

gulp.task('clean', (done) => {
	return rimraf('./dist/**/*', done);
});

gulp.task('serve', ['watch'], () => {
	connect.server({
		livereload: true,
		root: ['./dist/'],
		port: 3303
	});
});

gulp.task('pug', () => {
	return gulp.src('./src/app/[!_]*.pug')
		.pipe(plumb())
		.pipe(require('gulp-pug')({
			doctype: 'html5',
			pretty: false,
			locals: (function (def) {
				return merge(def, PUG_LOCALS);
			})({
				moment: moment,
				LOC: pkg.config.loc,
				SITE: require('./src/app/meta/site.json'),
				FRESH: ((returns) => {
					let limit = 4;

					if (returns.employment.history.length > limit) {
						returns.employment.history = returns.employment.history.splice(returns.employment.history.length - limit, limit);
					}

					return returns;
				})(pkg.fresh),
				_SKILLS: (([legend, fresh], returns) => {
					fresh.skills.sets.forEach(item => item.skills.forEach(skillItem => returns.push({
						zone: item.name,
						skill: skillItem,
						css: item.level
					})));

					return {
						list: orderBy(orderBy(returns, 'skill'), 'zone'),
						legend: legend
					};
				})([require('./src/app/meta/skills-legend.json'), pkg.fresh], [])
			})
		}))
		.pipe(require('gulp-posthtml')(((returns) => {
			returns.push(require('posthtml-minifier')({
				removeComments: true,
				collapseWhitespace: true,
				keepClosingSlash: true,
				sortClassName: true,
				minifyJS: true,
				minifyCSS: true
			}));

			if (process.env.NODE_ENV == 'production') {
				returns.push(require('posthtml-schemas')());
				returns.push(require('posthtml-json')());
				returns.push(require('posthtml-obfuscate')());
			}

			return returns;
		})([])))
		.pipe(gulp.dest('./dist/'))
		.pipe(connect.reload());
});

gulp.task('scss', () => {
	let srcMaps = require('gulp-sourcemaps');

	let returns = gulp.src('./src/assets/scss/main.scss')
		.pipe(plumb())
		.pipe(srcMaps.init())
		.pipe(require('gulp-sass-bulk-import')())
		.pipe(require('gulp-sass')({
			importer: require('sass-module-importer')()
		}))
		.pipe(require('gulp-postcss')((() => {
			let steps = [],
				prfxOpts = {
					//http://browserl.ist/?q=chrome+%3E%3D+51%2C+ie+%3E%3D+11%2C+edge+%3E%3D13%2C+safari+%3E%3D+9.1%2C+and_chr+%3E%3D+51%2C+ios+%3E+9.2
					browsers: [
						'chrome >= 50',
						'ie >= 11',
						'edge >=13',
						'safari >= 9.1',
						'and_chr >= 51',
						'ios > 9.2'
					],
					cascade: false,
					supports: true,
					add: true,
					remove: true
				};

			steps.push('postcss-position');
			steps.push('lost');
			steps.push(['postcss-pxtorem', {
				selectorBlackList: [/:root/i]
			}]);
			steps.push(['autoprefixer', prfxOpts]);

			steps.push(['css-mqpacker', {sort: true}]);

			if (process.env.NODE_ENV == 'production') {
				steps.push(['postcss-sorting', {'sort-order': require('cssortie')}]);
				steps.push(['cssnano', {
					discardComments: {removeAll: true},
					autoprefixer: prfxOpts,
					safe: false
				}]);
			}

			return steps.map(v => {
				if (typeof v == 'object') {
					return require(v[0])(v[1]);
				}

				return require(v);
			});
		})()));

	if (process.env.NODE_ENV != 'production') {
		returns.pipe(srcMaps.write());
	}

	return returns.pipe(gulp.dest('./dist/'))
		.pipe(connect.reload());
});

gulp.task('fonts', () => {
	return gulp.src('./src/assets/fonts/**/*')
		.pipe(gulp.dest('./dist/fonts/'));
});

gulp.task('images', () => {
	return gulp.src('./src/assets/img/**/*')
		.pipe(gulp.dest('./dist/img/'));
});

gulp.task('js', (done) => {
	if (watching) return done();

	require('webpack')(require('./webpack.config.js'), (err, stats) => {
		webpackCallback(err, stats);

		done();
	});
});

gulp.task('resume', (done) => {
	let fs = require('fs');
	let mkdirp = require('mkdirp');

	mkdirp('./dist/', err => {
		if (err != null) gutil.log(err);

		let fileOutput = fs.writeFileSync('./dist/resume.json', JSON.stringify(pkg.fresh));
		if (fileOutput != void 0) gutil.log(fileOutput);

		done();
	});
})

gulp.task('misc', ['resume'], () => {
	return gulp.src(['./src/misc/**/*'])
		.pipe(require('gulp-mustache')(PUG_LOCALS))
		.pipe(require('gulp-pretty-data')({type: 'minify'}))
		.pipe(gulp.dest('./dist'))
});

// If you want GZIP, using ['gzip'] here.
gulp.task('fingerprint', ['default', 'misc'], (done) => {
	const revAll = require('gulp-rev-all');

	gulp.src('./dist/**/*.{css,js,html}')
		.pipe(revAll.revision({dontRenameFile: ['.html']}))
		.pipe(gulp.dest('./dist/'))
		.on('end', () => {
			rimraf('./dist/main.{css,js}', done);
		});
});

gulp.task('gzip', ['default', 'misc'], () => {
	return gulp.src('./dist/**/*')
		.pipe(require('gulp-gzip')({
			append: false,
			gzipOptions: {
				level: 9
			}
		}))
		.pipe(gulp.dest('./dist/'));
});

gulp.task('publish', ['fingerprint'], () => {
	var awsPub = require('gulp-awspublish');

	var s3config = (function () {
		if (process.env.S3_BUCKET) {
			return {
				accessKeyId: process.env.S3_ACCESS_ID,
				secretAccessKey: process.env.S3_ACCESS_KEY,
				bucket: process.env.S3_BUCKET
			}
		} else {
			return require('./s3config.json');
		}
	})();

	var headers = {
			'Cache-Control': 'max-age=1209600'
		},
		s3base = {
			accessKeyId: s3config['accessKeyId'],
			secretAccessKey: s3config['secretAccessKey'],
			region: 'ap-southeast-2',
			params: {
				Bucket: s3config['bucket']
			}
		},
		rpt = {states: ['create', 'update', 'delete']},
		s3 = awsPub.create(s3base);

	return gulp.src('**/*', {cwd: 'dist/'})
		.pipe(parallelize(s3.publish(headers), 10))
		.pipe(s3.sync())
		.pipe(awsPub.reporter(rpt))
});
<commit_msg>fix: remove console.log<commit_after>const gulp = require('gulp'),
	gutil = require('gulp-util'),
	connect = require('gulp-connect'),
	orderBy = require('lodash.orderby'),
	merge = require('lodash.merge'),
	moment = require('moment-timezone'),
	pkg = require('./package.json'),
	rimraf = require('rimraf'),
	mustache = require('mustache'),
	parallelize = require("concurrent-transform");

let PUG_LOCALS = {
	LASTMOD: moment.tz(pkg.config.loc).format(),
	DOMAIN: (process.env.NODE_ENV == 'production') ? pkg.config.domain : 'http://localhost:3303/',
	VERSION: pkg.version
};

let watching = false;

Object.defineProperty(pkg, 'fresh', {
	get: () => ((fresh) => {
		fresh.employment = (emp => {
			emp.history = orderBy(emp.history, v => {
				return new Date(v.start).getUTCMilliseconds();
			});

			emp.history.forEach(item => {
				item.keywords.sort();
			});

			return emp;
		})(fresh.employment);

		return fresh;
	})(((fresh) => {
		return JSON.parse(mustache.render(fresh, PUG_LOCALS));
	})(JSON.stringify(require('./src/app/meta/fresh.json'))))
});

function plumb() {
	return require('gulp-plumber')({errorHandler: require('gulp-notify').onError("Error: <%= error.message %>")})
}

function webpackCallback(err, stats) {
	if (err) throw require('gulp-notify')()(err);

	gutil.log("[webpack]", stats.toString({
		colours: true,
		progress: true
	}));
}

gulp.task('default', ['images', 'js', 'scss', 'pug', 'fonts', 'images']);

gulp.task('prewatch', () => {
	watching = true;
});

gulp.task('watch', ['prewatch', 'default'], () => {
	gulp.watch('./src/app/**/*.pug', ['pug']);
	gulp.watch('./src/assets/**/*.scss', ['scss']);
	gulp.watch('./src/assets/img/**/*', ['images']);

	require('webpack')(Object.assign({watch: true}, require('./webpack.config.js')), (err, stats) => {
		webpackCallback(err, stats);
	});
});

gulp.task('clean', (done) => {
	return rimraf('./dist/**/*', done);
});

gulp.task('serve', ['watch'], () => {
	connect.server({
		livereload: true,
		root: ['./dist/'],
		port: 3303
	});
});

gulp.task('pug', () => {
	return gulp.src('./src/app/[!_]*.pug')
		.pipe(plumb())
		.pipe(require('gulp-pug')({
			doctype: 'html5',
			pretty: false,
			locals: (function (def) {
				return merge(def, PUG_LOCALS);
			})({
				moment: moment,
				LOC: pkg.config.loc,
				SITE: require('./src/app/meta/site.json'),
				FRESH: ((returns) => {
					let limit = 4;

					if (returns.employment.history.length > limit) {
						returns.employment.history = returns.employment.history.splice(returns.employment.history.length - limit, limit);
					}

					return returns;
				})(pkg.fresh),
				_SKILLS: (([legend, fresh], returns) => {
					fresh.skills.sets.forEach(item => item.skills.forEach(skillItem => returns.push({
						zone: item.name,
						skill: skillItem,
						css: item.level
					})));

					return {
						list: orderBy(orderBy(returns, 'skill'), 'zone'),
						legend: legend
					};
				})([require('./src/app/meta/skills-legend.json'), pkg.fresh], [])
			})
		}))
		.pipe(require('gulp-posthtml')(((returns) => {
			returns.push(require('posthtml-minifier')({
				removeComments: true,
				collapseWhitespace: true,
				keepClosingSlash: true,
				sortClassName: true,
				minifyJS: true,
				minifyCSS: true
			}));

			if (process.env.NODE_ENV == 'production') {
				returns.push(require('posthtml-schemas')());
				returns.push(require('posthtml-json')());
				returns.push(require('posthtml-obfuscate')());
			}

			return returns;
		})([])))
		.pipe(gulp.dest('./dist/'))
		.pipe(connect.reload());
});

gulp.task('scss', () => {
	let srcMaps = require('gulp-sourcemaps');

	let returns = gulp.src('./src/assets/scss/main.scss')
		.pipe(plumb())
		.pipe(srcMaps.init())
		.pipe(require('gulp-sass-bulk-import')())
		.pipe(require('gulp-sass')({
			importer: require('sass-module-importer')()
		}))
		.pipe(require('gulp-postcss')((() => {
			let steps = [],
				prfxOpts = {
					//http://browserl.ist/?q=chrome+%3E%3D+51%2C+ie+%3E%3D+11%2C+edge+%3E%3D13%2C+safari+%3E%3D+9.1%2C+and_chr+%3E%3D+51%2C+ios+%3E+9.2
					browsers: [
						'chrome >= 50',
						'ie >= 11',
						'edge >=13',
						'safari >= 9.1',
						'and_chr >= 51',
						'ios > 9.2'
					],
					cascade: false,
					supports: true,
					add: true,
					remove: true
				};

			steps.push('postcss-position');
			steps.push('lost');
			steps.push(['postcss-pxtorem', {
				selectorBlackList: [/:root/i]
			}]);
			steps.push(['autoprefixer', prfxOpts]);

			steps.push(['css-mqpacker', {sort: true}]);

			if (process.env.NODE_ENV == 'production') {
				steps.push(['postcss-sorting', {'sort-order': require('cssortie')}]);
				steps.push(['cssnano', {
					discardComments: {removeAll: true},
					autoprefixer: prfxOpts,
					safe: false
				}]);
			}

			return steps.map(v => {
				if (typeof v == 'object') {
					return require(v[0])(v[1]);
				}

				return require(v);
			});
		})()));

	if (process.env.NODE_ENV != 'production') {
		returns.pipe(srcMaps.write());
	}

	return returns.pipe(gulp.dest('./dist/'))
		.pipe(connect.reload());
});

gulp.task('fonts', () => {
	return gulp.src('./src/assets/fonts/**/*')
		.pipe(gulp.dest('./dist/fonts/'));
});

gulp.task('images', () => {
	return gulp.src('./src/assets/img/**/*')
		.pipe(gulp.dest('./dist/img/'));
});

gulp.task('js', (done) => {
	if (watching) return done();

	require('webpack')(require('./webpack.config.js'), (err, stats) => {
		webpackCallback(err, stats);

		done();
	});
});

gulp.task('resume', (done) => {
	let fs = require('fs');
	let mkdirp = require('mkdirp');

	mkdirp('./dist/', err => {
		if (err != null) gutil.log(err);

		let fileOutput = fs.writeFileSync('./dist/resume.json', JSON.stringify(pkg.fresh));
		if (fileOutput != void 0) gutil.log(fileOutput);

		done();
	});
})

gulp.task('misc', ['resume'], () => {
	return gulp.src(['./src/misc/**/*'])
		.pipe(require('gulp-mustache')(PUG_LOCALS))
		.pipe(require('gulp-pretty-data')({type: 'minify'}))
		.pipe(gulp.dest('./dist'))
});

// If you want GZIP, using ['gzip'] here.
gulp.task('fingerprint', ['default', 'misc'], (done) => {
	const revAll = require('gulp-rev-all');

	gulp.src('./dist/**/*.{css,js,html}')
		.pipe(revAll.revision({dontRenameFile: ['.html']}))
		.pipe(gulp.dest('./dist/'))
		.on('end', () => {
			rimraf('./dist/main.{css,js}', done);
		});
});

gulp.task('gzip', ['default', 'misc'], () => {
	return gulp.src('./dist/**/*')
		.pipe(require('gulp-gzip')({
			append: false,
			gzipOptions: {
				level: 9
			}
		}))
		.pipe(gulp.dest('./dist/'));
});

gulp.task('publish', ['fingerprint'], () => {
	var awsPub = require('gulp-awspublish');

	var s3config = (function () {
		if (process.env.S3_BUCKET) {
			return {
				accessKeyId: process.env.S3_ACCESS_ID,
				secretAccessKey: process.env.S3_ACCESS_KEY,
				bucket: process.env.S3_BUCKET
			}
		} else {
			return require('./s3config.json');
		}
	})();

	var headers = {
			'Cache-Control': 'max-age=1209600'
		},
		s3base = {
			accessKeyId: s3config['accessKeyId'],
			secretAccessKey: s3config['secretAccessKey'],
			region: 'ap-southeast-2',
			params: {
				Bucket: s3config['bucket']
			}
		},
		rpt = {states: ['create', 'update', 'delete']},
		s3 = awsPub.create(s3base);

	return gulp.src('**/*', {cwd: 'dist/'})
		.pipe(parallelize(s3.publish(headers), 10))
		.pipe(s3.sync())
		.pipe(awsPub.reporter(rpt))
});
<|endoftext|>


<commit_before>var gulp = require('gulp'),
    exec = require('child_process').exec;

gulp.task('test', function(cb) {
    exec(
		'node testrunner.js',
		{ cwd : 'tests' },
		function (err, stdout, stderr) {
			console.log(stdout);
			console.log(stderr);
			cb(err);
		}
	);
});

gulp.task('default', function() {
    gulp.watch(['**/*.js', 'tests/tests.json'], ['test']);
});
<commit_msg>Add an eslint config and update the code to match it.<commit_after>var gulp = require("gulp");
var exec = require("child_process").exec;

gulp.task("test", function(cb) {
  exec(
    "node testrunner.js",
    {cwd: "tests"},
    function(err, stdout, stderr) {
      console.log(stdout);
      console.log(stderr);
      cb(err);
    }
  );
});

gulp.task("default", function() {
  gulp.watch(["**/*.js", "tests/tests.json"], ["test"]);
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');

gulp.task('serve', ['sass'], function() {

	browserSync.init({
			server: {
					baseDir: "./"
			}
	});

	gulp.watch("./**/*.scss", ['sass']).on('change', browserSync.reload);
	gulp.watch("./js/**.js").on('change', browserSync.reload);
	gulp.watch("./*.html").on('change', browserSync.reload);

});

/* Need to make sure Angular will take the compression. */

// gulp.task('compress', function () {
// 	return gulp.src('./js/**/*.js')
// 		.pipe(minify())
// 		.pipe(gulp.dest('./build'));
// });

gulp.task('sass', function() {
    return gulp.src("./css/*.scss")
        .pipe(sass())
        .pipe(gulp.dest("./css"))
        .pipe(browserSync.stream());
});

gulp.task('test', function() {
	console.log('this is where my tests will go');
	return
});

gulp.task('default', ['serve']);
<commit_msg>small change to gulpfile<commit_after>var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');

gulp.task('serve', ['sass'], function() {

	browserSync.init({
			server: {
					baseDir: "./"
			}
	});

	gulp.watch("./**/*.scss", ['sass']).on('change', browserSync.reload);
	gulp.watch("./js/**.js").on('change', browserSync.reload);
	gulp.watch("./*.html").on('change', browserSync.reload);

});

/* Need to make sure Angular will take the compression. */

// gulp.task('compress', function () {
// 	return gulp.src('./js/**/*.js')
// 		.pipe(minify())
// 		.pipe(gulp.dest('./build'));
// });

gulp.task('sass', function() {
    return gulp.src("./css/*.scss")
        .pipe(sass())
        .pipe(gulp.dest("./css"))
        .pipe(browserSync.stream());
});

gulp.task('test', function() {
	console.log('this is where my tests will go');
	return;
});

gulp.task('default', ['serve']);
<|endoftext|>


<commit_before>var gulp    = require('gulp')
  , nodemon = require('gulp-nodemon')
  , concat  = require('gulp-concat')
  , harp    = require('harp')
  , browserSync = require('browser-sync');

gulp.task('browser-sync', ['nodemon'], function () {
    browserSync.init(null, {
        proxy: "localhost:3000"
      , port: 9000
      , open: false
    });
});

gulp.task('nodemon', function(){
    nodemon({
        script: 'app.js'
      , env : { 'NODE_ENV': 'development'}
    })
    .on('restart', function () {
        setTimeout(function () {
            browserSync.reload({stream: true});
        }, 500);
    });
});

gulp.task('script', function(){
    return gulp.src('public/modules/**/*.js')
    .pipe(concat('app-build.js'))
    .pipe(gulp.dest('public'));
});

gulp.task('watch', function() {

    //Watch jade files
    gulp.watch(['app/views/**/*.jade', 'public/modules/**/*.jade'], function(){
        browserSync.reload('index.html', { stream: true });
    });
    //Watch sass files
    gulp.watch('public/css/*.sass', function(){
        browserSync.reload('bitvagas.css', { stream: true });
    });
    //Watch js files
    gulp.watch('public/modules/**/*.js',['script'], function(){
        browserSync.reload('app-build.js', { stream: true });
    });
});

gulp.task('default', ['browser-sync', 'watch']);
<commit_msg>build javascript when application start<commit_after>var gulp    = require('gulp')
  , nodemon = require('gulp-nodemon')
  , concat  = require('gulp-concat')
  , harp    = require('harp')
  , browserSync = require('browser-sync');

gulp.task('browser-sync', ['nodemon'], function () {
    browserSync.init(null, {
        proxy: "localhost:3000"
      , port: 9000
      , open: false
    });
});

gulp.task('nodemon', function(){
    nodemon({
        script: 'app.js'
      , env : { 'NODE_ENV': 'development'}
    })
    .on('restart', function () {
        setTimeout(function () {
            browserSync.reload({stream: true});
        }, 500);
    });
});

gulp.task('script', function(){
    return gulp.src('public/modules/**/*.js')
    .pipe(concat('app-build.js'))
    .pipe(gulp.dest('public'));
});

gulp.task('watch', function() {

    //Watch jade files
    gulp.watch(['app/views/**/*.jade', 'public/modules/**/*.jade'], function(){
        browserSync.reload('index.html', { stream: true });
    });
    //Watch sass files
    gulp.watch('public/css/*.sass', function(){
        browserSync.reload('bitvagas.css', { stream: true });
    });
    //Watch js files
    gulp.watch('public/modules/**/*.js',['script'], function(){
        browserSync.reload('app-build.js', { stream: true });
    });
});

gulp.task('default', ['browser-sync','script', 'watch']);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var autoprefixer = require('autoprefixer');
var browserSync = require('browser-sync').create();
var config = {
	'src': './',
	'dest': 'dist/',
	'minify': true,
	'sourcemaps': false
};

// HTML
gulp.task('html', function() {
	return gulp.src('*.html')
		.pipe(browserSync.stream());
});

// Compile and autoprefix stylesheets
gulp.task('styles', function() {
	return gulp.src(config.src + 'scss/**/*.scss')
		.pipe($.if(config.sourcemaps, $.sourcemaps.init()))
		.pipe($.sass({
			precision: 8,
			outputStyle: 'expanded'
		}).on('error', function(error) {
			$.util.log($.util.colors.red(error.message));
			this.emit('end');
		}))
		.pipe($.postcss([
			autoprefixer()
		]))
		.pipe($.if(config.sourcemaps, $.sourcemaps.write()))
		.pipe(gulp.dest(config.dest + 'css'))
		.pipe(browserSync.stream())
		.pipe($.cleanCss({compatibility: 'ie9'}))
		.pipe($.if(config.sourcemaps, $.sourcemaps.write()))
		.pipe($.rename({suffix: '.min'}))
		.pipe($.if(config.minify, gulp.dest(config.dest + 'css')))
		.pipe(browserSync.stream());
});

// Lint stylesheets
gulp.task('stylelint', function() {
	return gulp.src(config.src + 'scss/**/*.scss')
		.pipe($.postcss([
			require('stylelint')
		], {
			syntax: require('postcss-scss')
		}));
});

// Compile javascript
gulp.task('scripts', function() {
	return gulp.src(config.src + 'js/*.js')
		.pipe($.include().on('error', function(error) {
			$.util.log($.util.colors.red(error.message));
			this.emit('end');
		}))
		.pipe(gulp.dest(config.dest + 'js'))
		.pipe(browserSync.stream())
		.pipe($.if(config.sourcemaps, $.sourcemaps.init()))
		.pipe($.uglify().on('error', function(error) {
			$.util.log($.util.colors.red(error.message));
			this.emit('end');
		}))
		.pipe($.if(config.sourcemaps, $.sourcemaps.write()))
		.pipe($.rename({suffix: '.min'}))
		.pipe($.if(config.minify, gulp.dest(config.dest + 'js')))
		.pipe(browserSync.stream());
});

// Lint javascript
gulp.task('eslint', function() {
	return gulp.src(config.src + 'js/**/*.js')
		.pipe($.eslint())
		.pipe($.eslint.format())
		.pipe($.eslint.failAfterError());
});

// Optimize images
gulp.task('images', function() {
	return gulp.src(config.src + 'img/**/*.{gif,jpg,png,svg}')
		.pipe($.cache($.imagemin()))
		.pipe(gulp.dest(config.dest + 'img'))
		.pipe(browserSync.stream());
});

// Build production files
gulp.task('build', ['html', 'styles', 'scripts', 'images']);

// Serve compiled files
gulp.task('serve', ['build'], function() {
	browserSync.init({
		server: true,
		notify: false,
		snippetOptions: {
			rule: {
				match: /<\/body>/i
			}
		}
		/*
		proxy: 'example.com',
		files: config.dest,
		serveStatic: [{
			route: '', // remote path
			dir: config.dest // local path
		}],
		*/
	});
});

// Watch files for changes
gulp.task('watch', function() {
	gulp.watch('*.html', ['html']);
	gulp.watch(config.src + 'scss/**/*.scss', ['styles']);
	gulp.watch(config.src + 'js/**/*.js', ['scripts']);
	gulp.watch(config.src + 'img/**/*.{gif,jpg,png,svg}', ['images']);
});

// Run all tasks
gulp.task('default', ['serve', 'watch']);
<commit_msg>Ignore scss files in subfolders<commit_after>var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var autoprefixer = require('autoprefixer');
var browserSync = require('browser-sync').create();
var config = {
	'src': './',
	'dest': 'dist/',
	'minify': true,
	'sourcemaps': false
};

// HTML
gulp.task('html', function() {
	return gulp.src('*.html')
		.pipe(browserSync.stream());
});

// Compile and autoprefix stylesheets
gulp.task('styles', function() {
	return gulp.src(config.src + 'scss/*.scss')
		.pipe($.if(config.sourcemaps, $.sourcemaps.init()))
		.pipe($.sass({
			precision: 8,
			outputStyle: 'expanded'
		}).on('error', function(error) {
			$.util.log($.util.colors.red(error.message));
			this.emit('end');
		}))
		.pipe($.postcss([
			autoprefixer()
		]))
		.pipe($.if(config.sourcemaps, $.sourcemaps.write()))
		.pipe(gulp.dest(config.dest + 'css'))
		.pipe(browserSync.stream())
		.pipe($.cleanCss({compatibility: 'ie9'}))
		.pipe($.if(config.sourcemaps, $.sourcemaps.write()))
		.pipe($.rename({suffix: '.min'}))
		.pipe($.if(config.minify, gulp.dest(config.dest + 'css')))
		.pipe(browserSync.stream());
});

// Lint stylesheets
gulp.task('stylelint', function() {
	return gulp.src(config.src + 'scss/**/*.scss')
		.pipe($.postcss([
			require('stylelint')
		], {
			syntax: require('postcss-scss')
		}));
});

// Compile javascript
gulp.task('scripts', function() {
	return gulp.src(config.src + 'js/*.js')
		.pipe($.include().on('error', function(error) {
			$.util.log($.util.colors.red(error.message));
			this.emit('end');
		}))
		.pipe(gulp.dest(config.dest + 'js'))
		.pipe(browserSync.stream())
		.pipe($.if(config.sourcemaps, $.sourcemaps.init()))
		.pipe($.uglify().on('error', function(error) {
			$.util.log($.util.colors.red(error.message));
			this.emit('end');
		}))
		.pipe($.if(config.sourcemaps, $.sourcemaps.write()))
		.pipe($.rename({suffix: '.min'}))
		.pipe($.if(config.minify, gulp.dest(config.dest + 'js')))
		.pipe(browserSync.stream());
});

// Lint javascript
gulp.task('eslint', function() {
	return gulp.src(config.src + 'js/**/*.js')
		.pipe($.eslint())
		.pipe($.eslint.format())
		.pipe($.eslint.failAfterError());
});

// Optimize images
gulp.task('images', function() {
	return gulp.src(config.src + 'img/**/*.{gif,jpg,png,svg}')
		.pipe($.cache($.imagemin()))
		.pipe(gulp.dest(config.dest + 'img'))
		.pipe(browserSync.stream());
});

// Build production files
gulp.task('build', ['html', 'styles', 'scripts', 'images']);

// Serve compiled files
gulp.task('serve', ['build'], function() {
	browserSync.init({
		server: true,
		notify: false,
		snippetOptions: {
			rule: {
				match: /<\/body>/i
			}
		}
		/*
		proxy: 'example.com',
		files: config.dest,
		serveStatic: [{
			route: '', // remote path
			dir: config.dest // local path
		}],
		*/
	});
});

// Watch files for changes
gulp.task('watch', function() {
	gulp.watch('*.html', ['html']);
	gulp.watch(config.src + 'scss/**/*.scss', ['styles']);
	gulp.watch(config.src + 'js/**/*.js', ['scripts']);
	gulp.watch(config.src + 'img/**/*.{gif,jpg,png,svg}', ['images']);
});

// Run all tasks
gulp.task('default', ['serve', 'watch']);
<|endoftext|>


<commit_before>var gulp = require("gulp");

require("../gulp-ps-tasks/tasks")(gulp);<commit_msg>Changed gulp-ps-tasks import path<commit_after>var gulp = require("gulp");

require("../tasks")(gulp);<|endoftext|>


<commit_before>/* eslint import/no-extraneous-dependencies: "off" */
const fs = require('fs');

const gulp = require('gulp');
const eslint = require('gulp-eslint');
const mocha = require('gulp-mocha');
const nodemon = require('gulp-nodemon');
const istanbul = require('gulp-istanbul');

const srcFiles = ['lib/**/*.js', 'model/**/*.js', 'route/**/*.js', 'gulpfile.js'];
const testFiles = ['test/test.js'];

const eslintRules = JSON.parse(fs.readFileSync('./.eslintrc'));

// Linter tasks -------------------------------------------
gulp.task('lint:src', () => (
  gulp.src(srcFiles)
    .pipe(eslint(eslintRules))
    .pipe(eslint.format())
    .pipe(eslint.failAfterError())
));

gulp.task('lint:test', () => (
  gulp.src(testFiles)
    .pipe(eslint(Object.assign(eslintRules, { envs: ['node', 'es6', 'mocha'] })))
    .pipe(eslint.format())
    .pipe(eslint.failAfterError())
));

gulp.task('lint', ['lint:src', 'lint:test']);

gulp.task('lint:watch', () => {
  gulp.watch(srcFiles, ['lint:src'])
    .on('change', (event) => {
      console.log(`File ${event.path} was ${event.type} running tasks...`);
    });

  gulp.watch(testFiles, ['lint:test'])
    .on('change', (event) => {
      console.log(`File ${event.path} was ${event.type} running tasks...`);
    });
});

// Test tasks ---------------------------------------------
gulp.task('pre-test', () => (
  gulp.src(srcFiles)
    .pipe(istanbul())
    .pipe(istanbul.hookRequire())
));

gulp.task('test', ['pre-test'], () => {
  process.env.SECRET = 'THIS IS A BAD SECRET';
  return gulp.src(testFiles, { read: false })
    .pipe(mocha({ reporter: 'spec' }))
    .pipe(istanbul.writeReports())
    .pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } }))
    .once('error', () => {
      process.exit(1);
    })
    .once('end', () => {
      process.exit();
    });
});

gulp.task('test:watch', ['test'], () => {
  gulp.watch([srcFiles, testFiles], ['test'])
    .on('change', (event) => {
      console.log(`File ${event.path} was ${event.type} running tasks...`);
    });
});

// Server tasks -------------------------------------------
gulp.task('start', ['lint', 'test'], () => {
  nodemon({ script: './lib/index.js' });
});

gulp.task('default', ['lint', 'test']);
gulp.task('watch', ['lint:watch', 'test:watch', 'start']);
<commit_msg>Lower expectations<commit_after>/* eslint import/no-extraneous-dependencies: "off" */
const fs = require('fs');

const gulp = require('gulp');
const eslint = require('gulp-eslint');
const mocha = require('gulp-mocha');
const nodemon = require('gulp-nodemon');
const istanbul = require('gulp-istanbul');

const srcFiles = ['lib/**/*.js', 'model/**/*.js', 'route/**/*.js', 'gulpfile.js'];
const testFiles = ['test/test.js'];

const eslintRules = JSON.parse(fs.readFileSync('./.eslintrc'));

// Linter tasks -------------------------------------------
gulp.task('lint:src', () => (
  gulp.src(srcFiles)
    .pipe(eslint(eslintRules))
    .pipe(eslint.format())
    .pipe(eslint.failAfterError())
));

gulp.task('lint:test', () => (
  gulp.src(testFiles)
    .pipe(eslint(Object.assign(eslintRules, { envs: ['node', 'es6', 'mocha'] })))
    .pipe(eslint.format())
    .pipe(eslint.failAfterError())
));

gulp.task('lint', ['lint:src', 'lint:test']);

gulp.task('lint:watch', () => {
  gulp.watch(srcFiles, ['lint:src'])
    .on('change', (event) => {
      console.log(`File ${event.path} was ${event.type} running tasks...`);
    });

  gulp.watch(testFiles, ['lint:test'])
    .on('change', (event) => {
      console.log(`File ${event.path} was ${event.type} running tasks...`);
    });
});

// Test tasks ---------------------------------------------
gulp.task('pre-test', () => (
  gulp.src(srcFiles)
    .pipe(istanbul())
    .pipe(istanbul.hookRequire())
));

gulp.task('test', ['pre-test'], () => {
  process.env.SECRET = 'THIS IS A BAD SECRET';
  return gulp.src(testFiles, { read: false })
    .pipe(mocha({ reporter: 'spec' }))
    .pipe(istanbul.writeReports())
    .pipe(istanbul.enforceThresholds({ thresholds: { global: 60 } }))
    .once('error', () => {
      process.exit(1);
    })
    .once('end', () => {
      process.exit();
    });
});

gulp.task('test:watch', ['test'], () => {
  gulp.watch([srcFiles, testFiles], ['test'])
    .on('change', (event) => {
      console.log(`File ${event.path} was ${event.type} running tasks...`);
    });
});

// Server tasks -------------------------------------------
gulp.task('start', ['lint', 'test'], () => {
  nodemon({ script: './lib/index.js' });
});

gulp.task('default', ['lint', 'test']);
gulp.task('watch', ['lint:watch', 'test:watch', 'start']);
<|endoftext|>


<commit_before>// gulpfile.js

// Packages
var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');

// Tasks

// Uglify
gulp.task('games-js', function(){

    return gulp
        .src('resources/assets/js/games/index.js')
        //.pipe(rename('index.min.js'))
        .pipe(rename({suffix: '.min'}))
        .pipe(uglify())
        .pipe(gulp.dest('public/js/games'));

});

// Browserify & Babel
gulp.task('users-js', function(){

    return browserify('resources/assets/js/users/index.js')
        .transform('babelify', {presets: ['es2015']})
        .bundle()
        .pipe(source('user-bundle.min.js'))
        .pipe(buffer())
        .pipe(uglify())
        .pipe(gulp.dest('public/js/users'));

});
<commit_msg>Refactor Gulpfile for Gulp Watch<commit_after>// gulpfile.js

// Packages
var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');

// Tasks

var bundleGames = function() {

    return gulp
        .src('resources/assets/js/games/index.js')
        //.pipe(rename('index.min.js'))
        .pipe(rename({suffix: '.min'}))
        .pipe(uglify())
        .pipe(gulp.dest('public/js/games'));

}

var bundleUsers = function() {

    return browserify('resources/assets/js/users/index.js')
        .transform('babelify', {presets: ['es2015']})
        .bundle()
        .pipe(source('user-bundle.min.js'))
        .pipe(buffer())
        .pipe(uglify())
        .pipe(gulp.dest('public/js/users'));

}

// Uglify
gulp.task('games-js', function(){
    return bundleUsers();
});

// Browserify & Babel
gulp.task('users-js', function(){
    return bundleUsers();
});
<|endoftext|>