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

var less = require('gulp-less');
var gulpkss = require('gulp-kss');
var cachebust = require('gulp-cache-bust');
var concat = require('gulp-concat');
var config = require('./config.json');
var iconfont = require('gulp-iconfont');
var consolidate = require('gulp-consolidate');
var zip = require('gulp-zip');
var LessPluginCleanCSS = require('less-plugin-clean-css'),
    LessPluginAutoPrefix = require('less-plugin-autoprefix'),
    cleancss = new LessPluginCleanCSS({ advanced: false, aggressiveMerging:true }),
    autoprefix= new LessPluginAutoPrefix({ browsers: ["Safari >= 8", "last 2 versions", "ie >= 9"] });

const browserSync = require('browser-sync').create();

const yargs = require('yargs');
const PRODUCTION = !!(yargs.argv.production);
const DEVELOPMENT = !!(yargs.argv.development);

var paths = {
    icons_path: 'src/icons/*.svg',
    bootstrap_icons: 'bower_components/bootstrap/fonts/**/*',
    scripts: 'src/js/**/*',
    less: [
        'src/less/**/*.less',
        '!src/less/**/_*.less'
    ],
    less_watch: [
        'src/less/**/*.less',
        '!src/less/globals/_resource-paths.less'
    ],
    doc_less: 'src/less/**/*.less',
    doc_markdown: 'docs/markdown/**/*',
    doc_template: 'docs/template/**/*',
    html: [
        'src/html/**/*.html'
    ],
    environment: 'dist'
};

/**
 * Font settings
 */
const fontName = 'hyicon' // set name of your symbol font
const className = 'hyicon' // set class name in your CSS

// Create Iconfont
gulp.task('iconfont', function() {
    gulp.src(paths.icons_path)
        .pipe(iconfont({
            fontName,
            formats: ['ttf', 'eot', 'woff', 'woff2', 'svg'],
            normalize: true,
            centerHorizontally: true,
            fontHeight: 100, // IMPORTANT
            prependUnicode: true
        }))
        .on('glyphs', (glyphs) => {
          const options = {
            className,
            fontName,
            fontPath: '/fonts/',
            glyphs: glyphs.map(mapGlyphs)
          }
          gulp.src(`src/less/templates/_icons.less`)
            .pipe(consolidate('lodash', options))
            .pipe(gulp.dest('src/less/components')) // set path to export your CSS
        })
        .pipe( gulp.dest('dist/techne/fonts/') );
    }
);
function mapGlyphs (glyph) {
  return { name: glyph.name, codepoint: glyph.unicode[0].charCodeAt(0) }
}

gulp.task('setpath', function(cb) {
    gulp.src('src/less/templates/_resource-paths.less')
        .pipe(
            consolidate('lodash',
                {
                    bootstrap_path: config.bootstrap_path,
                    bower_path: config.bower_path
                }
            )
        )
        .pipe(
            gulp.dest('src/less/globals')
        );
    cb(); // Callback to less task
});

// Complile general Less Files
gulp.task('less', ['setpath'], () => {
    return gulp.src(paths.less)
        .pipe(less({
            errLogToConsole: true,
            plugins: [autoprefix, cleancss]
        }))
        .on('error', (err) => {
            console.log(err.message);
        })
        .pipe(cachebust({
            type: 'timestamp'
        }))
        .pipe(concat('techne.min.css'))
        .pipe(gulp.dest( paths.environment+'/techne/css/' ))
});

//----ABOVE COMPLETE----

// Complile general Less Files
gulp.task('html',
    function ()
    {
        gulp.src(paths.html)
        .pipe(cachebust({
            type: 'timestamp'
        }))
        .pipe(
            gulp.dest('docs/')
        );
    }
);

// Generate Docs
gulp.task('styleguide', function () {

    gulp.src(paths.doc_less)
    .pipe(
        gulpkss(
            {
                markDownDirectory: __dirname + '/docs/markdown/',
                templateDirectory: __dirname + '/docs/template'
            }
        )
    )
    .pipe(cachebust({
        type: 'timestamp'
    }))
    .pipe(gulp.dest('docs/kss') )
    //.pipe(browserSync.stream());

    gulp.src('./bower_components/bootstrap/fonts/**/*')
    .pipe( gulp.dest('./docs/kss/public/bootstrap/fonts') );
});

// Static server
gulp.task('serve', function() {
    browserSync.init({
        server: {
            baseDir: __dirname + '/docs/kss'
        },
        port: 8080,
        open: DEVELOPMENT
    });
    gulp.watch(paths.less_watch, ['watch-styleguide']);
    gulp.watch('docs/kss/public/dist/techne/css/techne.min.css').on('change', browserSync.reload);
});

// these custom tasks are here to avoid calling deploy to do this one thing
gulp.task('watch-css', ['less'], () => {
    //copy compiled minified CSS to docs public/dist folder
    return gulp.src('dist/techne/css/techne.min.css')
        .pipe(gulp.dest('docs/kss/public/dist/techne/css/'));
});
gulp.task('watch-styleguide', ['styleguide', 'watch-css'], () => {

});

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

    /*
    JS
     */
    gulp.src(
        [
            './bower_components/jquery/dist/jquery.min.js',
            './bower_components/bootstrap/dist/js/bootstrap.min.js',
            './bower_components/select2/select2.js',
            './bower_components/Jcrop/js/jquery.Jcrop.min.js',
            './src/js/**/*.js'
        ]
    ).pipe(gulp.dest(paths.environment+'/js/'));

    gulp.src('./bower_components/jquery/dist/jquery.min.js')
    .pipe(gulp.dest('docs/kss/public/js/'));

    /*
    Create the distribution zip file
     */
    gulp.src('dist/**/*')
    .pipe( zip('techne'+require('./bower.json').version+ '.zip') )
    .pipe( gulp.dest('docs/kss/public/release-archive/') );

    gulp.src('dist/bootstrap/**/*')
    .pipe( gulp.dest('docs/kss/public/dist/bootstrap/') );

    gulp.src('dist/js/**/*')
    .pipe( gulp.dest('docs/kss/public/dist/js/') );

    gulp.src('dist/techne/**/*')
    .pipe( gulp.dest('docs/kss/public/dist/techne/') );

    gulp.src([
            './bower_components/Jcrop/css/jquery.Jcrop.min.css',
            './bower_components/Jcrop/css/Jcrop.gif'
        ])
        .pipe(gulp.dest('docs/kss/public/dist/vendor/'));

    // gulp.src(['bower_components/bootstrap/**/*'])
    // .pipe( gulp.dest('docs/kss/bower_components/bootstrap') );

});

gulp.task('patchgulpkss',
    function(){
        //patch the gulp-kss main branch
        gulp.src('./gulp-patch/gulp-kss/**/*.js').pipe(gulp.dest('./node_modules/gulp-kss'));
        //patch the gulp-kss depednecy of kss
        gulp.src('./gulp-patch/kss/**/*.js').pipe(gulp.dest('./node_modules/gulp-kss/node_modules/kss/lib'));
        gulp.src('./gulp-patch/kss/**/*.js').pipe(gulp.dest('./node_modules/kss/lib'));
    }
);

gulp.task('packagedist',
  function()
  {
    //copies files to the dist folder
    gulp.src('./bower_components/bootstrap/fonts/**/*').pipe( gulp.dest('dist/bootstrap/fonts') );
  }
);

gulp.task('build', ['less', 'patchgulpkss', 'styleguide', 'packagedist', 'deploy']);

// iconfont, less, kss_bootrap_src
gulp.task('dist', ['iconfont', 'build']);

// The default task (called when you run `gulp` from cli)
gulp.task('default', [ 'build' , 'serve']);

<commit_msg>CCE-644 : added separate gulp task.<commit_after>var gulp = require('gulp');

var less = require('gulp-less');
var gulpkss = require('gulp-kss');
var cachebust = require('gulp-cache-bust');
var concat = require('gulp-concat');
var config = require('./config.json');
var iconfont = require('gulp-iconfont');
var consolidate = require('gulp-consolidate');
var zip = require('gulp-zip');
var LessPluginCleanCSS = require('less-plugin-clean-css'),
    LessPluginAutoPrefix = require('less-plugin-autoprefix'),
    cleancss = new LessPluginCleanCSS({ advanced: false, aggressiveMerging:true }),
    autoprefix= new LessPluginAutoPrefix({ browsers: ["Safari >= 8", "last 2 versions", "ie >= 9"] });

const browserSync = require('browser-sync').create();

const yargs = require('yargs');
const PRODUCTION = !!(yargs.argv.production);
const DEVELOPMENT = !!(yargs.argv.development);

var paths = {
    icons_path: 'src/icons/*.svg',
    bootstrap_icons: 'bower_components/bootstrap/fonts/**/*',
    scripts: 'src/js/**/*',
    less: [
        'src/less/**/*.less',
        '!src/less/**/_*.less'
    ],
    less_watch: [
        'src/less/**/*.less',
        '!src/less/globals/_resource-paths.less'
    ],
    doc_less: 'src/less/**/*.less',
    doc_markdown: 'docs/markdown/**/*',
    doc_template: 'docs/template/**/*',
    html: [
        'src/html/**/*.html'
    ],
    environment: 'dist'
};

/**
 * Font settings
 */
const fontName = 'hyicon' // set name of your symbol font
const className = 'hyicon' // set class name in your CSS

// Create Iconfont
gulp.task('iconfont', function() {
    gulp.src(paths.icons_path)
        .pipe(iconfont({
            fontName,
            formats: ['ttf', 'eot', 'woff', 'woff2', 'svg'],
            normalize: true,
            centerHorizontally: true,
            fontHeight: 100, // IMPORTANT
            prependUnicode: true
        }))
        .on('glyphs', (glyphs) => {
          const options = {
            className,
            fontName,
            fontPath: '/fonts/',
            glyphs: glyphs.map(mapGlyphs)
          }
          gulp.src(`src/less/templates/_icons.less`)
            .pipe(consolidate('lodash', options))
            .pipe(gulp.dest('src/less/components')) // set path to export your CSS
        })
        .pipe( gulp.dest('dist/techne/fonts/') );
    }
);
function mapGlyphs (glyph) {
  return { name: glyph.name, codepoint: glyph.unicode[0].charCodeAt(0) }
}

gulp.task('setpath', function(cb) {
    gulp.src('src/less/templates/_resource-paths.less')
        .pipe(
            consolidate('lodash',
                {
                    bootstrap_path: config.bootstrap_path,
                    bower_path: config.bower_path
                }
            )
        )
        .pipe(
            gulp.dest('src/less/globals')
        );
    cb(); // Callback to less task
});

// Complile general Less Files
gulp.task('less', ['setpath'], () => {
    return gulp.src(paths.less)
        .pipe(less({
            errLogToConsole: true,
            plugins: [autoprefix, cleancss]
        }))
        .on('error', (err) => {
            console.log(err.message);
        })
        .pipe(cachebust({
            type: 'timestamp'
        }))
        .pipe(concat('techne.min.css'))
        .pipe(gulp.dest( paths.environment+'/techne/css/' ))
});

//----ABOVE COMPLETE----

// Complile general Less Files
gulp.task('html',
    function ()
    {
        gulp.src(paths.html)
        .pipe(cachebust({
            type: 'timestamp'
        }))
        .pipe(
            gulp.dest('docs/')
        );
    }
);

// Generate Docs
gulp.task('styleguide', function () {

    gulp.src(paths.doc_less)
    .pipe(
        gulpkss(
            {
                markDownDirectory: __dirname + '/docs/markdown/',
                templateDirectory: __dirname + '/docs/template'
            }
        )
    )
    .pipe(cachebust({
        type: 'timestamp'
    }))
    .pipe(gulp.dest('docs/kss') )
    //.pipe(browserSync.stream());

    gulp.src('./bower_components/bootstrap/fonts/**/*')
    .pipe( gulp.dest('./docs/kss/public/bootstrap/fonts') );
});

// Static server
gulp.task('serve', function() {
    browserSync.init({
        server: {
            baseDir: __dirname + '/docs/kss'
        },
        port: 8080,
        open: DEVELOPMENT
    });
    gulp.watch(paths.less_watch, ['watch-styleguide']);
    gulp.watch('docs/kss/public/dist/techne/css/techne.min.css').on('change', browserSync.reload);
});

// these custom tasks are here to avoid calling deploy to do this one thing
gulp.task('watch-css', ['less'], () => {
    //copy compiled minified CSS to docs public/dist folder
    return gulp.src('dist/techne/css/techne.min.css')
        .pipe(gulp.dest('docs/kss/public/dist/techne/css/'));
});
gulp.task('watch-styleguide', ['styleguide', 'watch-css'], () => {

});

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

    /*
    JS
     */
    gulp.src(
        [
            './bower_components/jquery/dist/jquery.min.js',
            './bower_components/bootstrap/dist/js/bootstrap.min.js',
            './bower_components/select2/select2.js',
            './bower_components/Jcrop/js/jquery.Jcrop.min.js',
            './src/js/**/*.js'
        ]
    ).pipe(gulp.dest(paths.environment+'/js/'));

    gulp.src('./bower_components/jquery/dist/jquery.min.js')
    .pipe(gulp.dest('docs/kss/public/js/'));

    /*
    Create the distribution zip file
     */
    gulp.src('dist/**/*')
    .pipe( zip('techne'+require('./bower.json').version+ '.zip') )
    .pipe( gulp.dest('docs/kss/public/release-archive/') );

    gulp.src('dist/bootstrap/**/*')
    .pipe( gulp.dest('docs/kss/public/dist/bootstrap/') );

    gulp.src('dist/js/**/*')
    .pipe( gulp.dest('docs/kss/public/dist/js/') );

    gulp.src('dist/techne/**/*')
    .pipe( gulp.dest('docs/kss/public/dist/techne/') );

    gulp.src([
            './bower_components/Jcrop/css/jquery.Jcrop.min.css',
            './bower_components/Jcrop/css/Jcrop.gif'
        ])
        .pipe(gulp.dest('docs/kss/public/dist/vendor/'));

    // gulp.src(['bower_components/bootstrap/**/*'])
    // .pipe( gulp.dest('docs/kss/bower_components/bootstrap') );

});

gulp.task('patchgulpkss',
    function(){
        //patch the gulp-kss main branch
        gulp.src('./gulp-patch/gulp-kss/**/*.js').pipe(gulp.dest('./node_modules/gulp-kss'));
        //patch the gulp-kss depednecy of kss
        gulp.src('./gulp-patch/kss/**/*.js').pipe(gulp.dest('./node_modules/gulp-kss/node_modules/kss/lib'));
        gulp.src('./gulp-patch/kss/**/*.js').pipe(gulp.dest('./node_modules/kss/lib'));
    }
);

gulp.task('packagedist',
  function()
  {
    //copies files to the dist folder
    gulp.src('./bower_components/bootstrap/fonts/**/*').pipe( gulp.dest('dist/bootstrap/fonts') );
  }
);

// seperate task to copy file in kss
gulp.task('copyToKss', function(){
    gulp.src('./dist/techne/**/*')
    .pipe( gulp.dest('./docs/kss/public/dist/techne/') );
});

gulp.task('build', ['less', 'patchgulpkss', 'styleguide', 'packagedist', 'deploy']);

// iconfont, less, kss_bootrap_src
gulp.task('dist', ['iconfont', 'build']);

// The default task (called when you run `gulp` from cli)
gulp.task('default', [ 'build' , 'serve']);

<|endoftext|>


<commit_before>var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var pkg = require('./package.json');

// Copy vendor files from /node_modules into /vendor
// NOTE: requires `npm install` before running!
gulp.task('copy', function() {
  gulp.src([
      'node_modules/bootstrap/dist/**/*',
      '!**/npm.js',
      '!**/bootstrap-theme.*',
      '!**/*.map'
    ])
    .pipe(gulp.dest('vendor/bootstrap'))

  gulp.src(['node_modules/jquery/dist/jquery.js', 'node_modules/jquery/dist/jquery.min.js'])
    .pipe(gulp.dest('vendor/jquery'))

  gulp.src(['node_modules/popper.js/dist/umd/popper.js', 'node_modules/popper.js/dist/umd/popper.min.js'])
    .pipe(gulp.dest('vendor/popper'))
})

// Default task
gulp.task('default', ['copy']);

// Configure the browserSync task
gulp.task('browserSync', function() {
  browserSync.init({
    server: {
      baseDir: ''
    },
  })
})

// Dev task with browserSync
gulp.task('dev', ['browserSync'], function() {
  // Reloads the browser whenever HTML or CSS files change
  gulp.watch('css/*.css', browserSync.reload);
  gulp.watch('*.html', browserSync.reload);
});
<commit_msg>remove popper from gulpfile<commit_after>var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var pkg = require('./package.json');

// Copy vendor files from /node_modules into /vendor
// NOTE: requires `npm install` before running!
gulp.task('copy', function() {
  gulp.src([
      'node_modules/bootstrap/dist/**/*',
      '!**/npm.js',
      '!**/bootstrap-theme.*',
      '!**/*.map'
    ])
    .pipe(gulp.dest('vendor/bootstrap'))

  gulp.src(['node_modules/jquery/dist/jquery.js', 'node_modules/jquery/dist/jquery.min.js'])
    .pipe(gulp.dest('vendor/jquery'))
})

// Default task
gulp.task('default', ['copy']);

// Configure the browserSync task
gulp.task('browserSync', function() {
  browserSync.init({
    server: {
      baseDir: ''
    },
  })
})

// Dev task with browserSync
gulp.task('dev', ['browserSync'], function() {
  // Reloads the browser whenever HTML or CSS files change
  gulp.watch('css/*.css', browserSync.reload);
  gulp.watch('*.html', browserSync.reload);
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var args = require('yargs').argv;
var config = require('./gulp.config')();
var $ = require('gulp-load-plugins')({lazy: true});
var del = require('del');

gulp.task('help',$.taskListing);

gulp.task('scripts', ['clean-scripts'], function() {
  log('Analyzing source with JSHint and JSCS');
  return gulp
    .src('./js/*.js')
    .pipe($.if(args.verbose, $.print()))
    .pipe($.plumber())
    .pipe($.jshint())
    .pipe($.jshint.reporter('jshint-stylish'))
    .pipe($.uglify())
    .pipe($.concat('bible.js'))
    .pipe(gulp.dest(config.build + 'js'));
});

gulp.task('styles', ['clean-styles'], function() {
  log('Compiling SCSS --> CSS');
  return gulp
    .src('./scss/**/*.scss')
    .pipe($.sassGlob())
    .pipe($.sass().on('error', $.sass.logError))
    .pipe($.csslint('./csslintrc.json'))
    .pipe($.csslint.reporter())
    .pipe($.autoprefixer({browsers: ['last 2 version', '> 5%']}))
    .pipe(gulp.dest(config.build + 'css'));
});

// gulp.task('clean')

gulp.task('fonts', ['clean-fonts'], function() {
  log('Copying fonts to build directory');
  return gulp
    .src(config.fonts)
    .pipe(gulp.dest(config.build + 'fonts'));
});

gulp.task('clean', function() {
  var delconfig = [].concat(config.build);
  log('Cleaning: ' + $.util.colors.green(delconfig));
  del(delconfig);
});

gulp.task('clean-scripts', function() {
  clean(config.build + 'js');
});

gulp.task('clean-styles', function() {
  clean(config.build + 'css');
});

gulp.task('clean-fonts', function() {
  clean(config.build + 'fonts');
});

gulp.task('clean-images', function() {
  clean(config.build + 'images');
});

gulp.task('watch', function() {
  gulp.watch('./js/*.js', ['js']);
  gulp.watch('./scss/**/*.scss', ['styles']);
});

gulp.task('default', ['fonts', 'scripts', 'styles', 'watch']);

////////////

function clean(path) {
  log('Cleaning ' + $.util.colors.green(path));
  del(path);
}

function log(msg) {
  if (typeof(msg) === 'object') {
    for (var item in msg) {
      if (msg.hasOwnProperty(item)) {
        $.util.log($.util.colors.green(msg(item)));
      }
    }
  } else {
    $.util.log($.util.colors.green(msg));
  }
}
<commit_msg>Update gulpfile.js<commit_after>var gulp = require('gulp');
var args = require('yargs').argv;
var config = require('./gulp.config')();
var $ = require('gulp-load-plugins')({lazy: true});
var del = require('del');

gulp.task('help',$.taskListing);

gulp.task('scripts', ['clean-scripts'], function() {
  log('Analyzing source with JSHint and JSCS');
  return gulp
    .src('./js/*.js')
    .pipe($.if(args.verbose, $.print()))
    .pipe($.plumber())
    .pipe($.jshint())
    .pipe($.jshint.reporter('jshint-stylish'))
    .pipe($.uglify())
    .pipe($.concat('bible.js'))
    .pipe(gulp.dest(config.build + 'js'));
});

gulp.task('styles', ['clean-styles'], function() {
  log('Compiling SCSS --> CSS');
  return gulp
    .src('./scss/**/*.scss')
    .pipe($.sassGlob())
    .pipe($.sass().on('error', $.sass.logError))
    .pipe($.csslint('./csslintrc.json'))
    .pipe($.csslint.reporter())
    .pipe($.autoprefixer({browsers: ['last 2 version', '> 5%']}))
    .pipe(gulp.dest(config.build + 'css'));
});

gulp.task('fonts', ['clean-fonts'], function() {
  log('Copying fonts to build directory');
  return gulp
    .src(config.fonts)
    .pipe(gulp.dest(config.build + 'fonts'));
});

gulp.task('clean', function() {
  var delconfig = [].concat(config.build);
  log('Cleaning: ' + $.util.colors.green(delconfig));
  del(delconfig);
});

gulp.task('clean-scripts', function() {
  clean(config.build + 'js');
});

gulp.task('clean-styles', function() {
  clean(config.build + 'css');
});

gulp.task('clean-fonts', function() {
  clean(config.build + 'fonts');
});

gulp.task('clean-images', function() {
  clean(config.build + 'images');
});

gulp.task('watch', function() {
  gulp.watch('./js/*.js', ['js']);
  gulp.watch('./scss/**/*.scss', ['styles']);
});

gulp.task('default', ['fonts', 'scripts', 'styles', 'watch']);

////////////

function clean(path) {
  log('Cleaning ' + $.util.colors.green(path));
  del(path);
}

function log(msg) {
  if (typeof(msg) === 'object') {
    for (var item in msg) {
      if (msg.hasOwnProperty(item)) {
        $.util.log($.util.colors.green(msg(item)));
      }
    }
  } else {
    $.util.log($.util.colors.green(msg));
  }
}
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var jshint = require('gulp-jshint');
var complexity = require('gulp-complexity');
var jscs = require('gulp-jscs-with-reporter');
var nsp = require('gulp-nsp');
var zip = require('gulp-zip');
var gutil = require('gulp-util');

//test myself
var sourceFiles = ['slushfile.js'];

function getIncludes() {
    var files = sourceFiles;
    var pkg = require('./package.json');

    Object.keys(pkg.dependencies).forEach(function (mod) {
        files.push('node_modules/' + mod + "**/*.*");
    });

    return files;
}

gulp.task('test', function (done) {

    gulp.src(['lib/**/*.js', 'operations/**/*.js'])
        .pipe(istanbul()) // Covering files
        .pipe(istanbul.hookRequire()) // Force `require` to return covered files
        .on('finish', function () {
            return gulp.src(['test/**/*.spec.js'])
                .pipe(mocha())
                .on('error', gutil.log)
                .pipe(istanbul.writeReports()) // Creating the reports after tests ran
                .pipe(istanbul.enforceThresholds({thresholds: {global: 100}})) // Enforce a coverage of at least 100%
                .on('end', done);

        })
        .on('error', gutil.log);
});

gulp.task('style', function () {
    var jscsConfig = require('./jscs.json');

    return gulp.src(sourceFiles)
        .pipe(jscs(jscsConfig))
        .pipe(jscs.reporter('inline'))
        .pipe(jscs.reporter('gulp-jscs-html-reporter', {
            filename: __dirname + '/style.html',
            createMissingFolders: false
        }))
        .pipe(jscs.reporter('fail'));
});

gulp.task('lint', function () {
    var jshintConfig = require('./jshint.json');
    return gulp.src(sourceFiles)
        .pipe(jshint(jshintConfig))
        .pipe(jshint.reporter('default'))
        .pipe(jshint.reporter('gulp-jshint-html-reporter',
            {
                filename: __dirname + '/lint.html',
                createMissingFolders: false
            }))
        .pipe(jshint.reporter('fail'));
});

gulp.task('complexity', function () {
    return gulp.src(sourceFiles)
        .pipe(complexity(
            {
                cyclomatic: 10,
                halstead: 15,
                maintainability: 100,
                breakOnErrors: true
            }
        ));
});

gulp.task('nsp', function (done) {
    nsp('./package.json', done);
});

gulp.task('package', function () {
    return gulp.src(getIncludes(), {base: './'})
        .pipe(zip('service.zip'))
        .pipe(gulp.dest('.'));
});

gulp.task('default', ['test', 'lint', 'style', 'complexity', 'package']);
<commit_msg>The default gulp task should not execute the package task<commit_after>'use strict';

var gulp = require('gulp');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var jshint = require('gulp-jshint');
var complexity = require('gulp-complexity');
var jscs = require('gulp-jscs-with-reporter');
var nsp = require('gulp-nsp');
var zip = require('gulp-zip');
var gutil = require('gulp-util');

//test myself
var sourceFiles = ['slushfile.js'];

function getIncludes() {
    var files = sourceFiles;
    var pkg = require('./package.json');

    Object.keys(pkg.dependencies).forEach(function (mod) {
        files.push('node_modules/' + mod + "**/*.*");
    });

    return files;
}

gulp.task('test', function (done) {

    gulp.src(['lib/**/*.js', 'operations/**/*.js'])
        .pipe(istanbul()) // Covering files
        .pipe(istanbul.hookRequire()) // Force `require` to return covered files
        .on('finish', function () {
            return gulp.src(['test/**/*.spec.js'])
                .pipe(mocha())
                .on('error', gutil.log)
                .pipe(istanbul.writeReports()) // Creating the reports after tests ran
                .pipe(istanbul.enforceThresholds({thresholds: {global: 100}})) // Enforce a coverage of at least 100%
                .on('end', done);

        })
        .on('error', gutil.log);
});

gulp.task('style', function () {
    var jscsConfig = require('./jscs.json');

    return gulp.src(sourceFiles)
        .pipe(jscs(jscsConfig))
        .pipe(jscs.reporter('inline'))
        .pipe(jscs.reporter('gulp-jscs-html-reporter', {
            filename: __dirname + '/style.html',
            createMissingFolders: false
        }))
        .pipe(jscs.reporter('fail'));
});

gulp.task('lint', function () {
    var jshintConfig = require('./jshint.json');
    return gulp.src(sourceFiles)
        .pipe(jshint(jshintConfig))
        .pipe(jshint.reporter('default'))
        .pipe(jshint.reporter('gulp-jshint-html-reporter',
            {
                filename: __dirname + '/lint.html',
                createMissingFolders: false
            }))
        .pipe(jshint.reporter('fail'));
});

gulp.task('complexity', function () {
    return gulp.src(sourceFiles)
        .pipe(complexity(
            {
                cyclomatic: 10,
                halstead: 15,
                maintainability: 100,
                breakOnErrors: true
            }
        ));
});

gulp.task('nsp', function (done) {
    nsp('./package.json', done);
});

gulp.task('package', function () {
    return gulp.src(getIncludes(), {base: './'})
        .pipe(zip('service.zip'))
        .pipe(gulp.dest('.'));
});

gulp.task('default', ['test', 'lint', 'style', 'complexity']);
<|endoftext|>


<commit_before>// less
var gulp = require('gulp');
var less = require('gulp-less');
var autoprefixer = require('gulp-autoprefixer');
var minifyCSS = require('gulp-minify-css');
var notify = require('gulp-notify');
var rename = require("gulp-rename");
var uncss = require('gulp-uncss');

// js
var gulpConcat = require('gulp-concat');
var uglify = require('gulp-uglify');

// less vars
var lessWatchFolder = './css/less/**/*.less';
var lessFile = './css/less/etherwallet-master.less';
var lessOutputFolder = './css';
var lessOutputFile = 'etherwallet-master.css';
var lessOutputFileMin = 'etherwallet-master.min.css';

//js vars
var jsWatchFolder = './js/**/*.js';
var jsFiles = "./js/**/*.js";
var jsOutputFolder = './js';
var jsOutputFile = 'etherwallet-master.js';

gulp.task('less', function (cb) {
  return gulp
    .src(lessFile)
      .pipe(less({ compress: false })).on('error', notify.onError(function (error) {
        return "ERROR! Problem file : " + error.message;
      }))
      .pipe(autoprefixer('last 2 version', 'ie 9', 'ios 6', 'android 4'))
      .pipe(rename(lessOutputFile))
      .pipe(gulp.dest(lessOutputFolder))

      .pipe(minifyCSS({keepBreaks: false}))
      .pipe(rename(lessOutputFileMin))
      .pipe(gulp.dest(lessOutputFolder))
      .pipe(notify('Less Compiled and Minified'));
});

gulp.task('less-uncss', ['less'], function () {
  return gulp
    .src('./css/' + lessOutputFile)
      .pipe(uncss({
        html: [
          './index.html'
        ]
      }))
      .pipe(minifyCSS({keepBreaks: false}))
      .pipe(rename(lessOutputFileMin))
      .pipe(gulp.dest(lessOutputFolder))
    .pipe(notify('Less UnCSS and Minified'));
});

gulp.task('minJS', function () {
  return gulp
    .src(jsFiles)
      .pipe(gulpConcat(jsOutputFile))
      .pipe(uglify())
      .pipe(gulp.dest(jsOutputFolder))
    .pipe(notify('JS Concat and Uglified'));
});

gulp.task('watch', function() {
    gulp.watch(lessWatchFolder, ['less', 'watch']);
    gulp.watch(jsWatchFolder, ['minJS', 'watch']);
});

gulp.task('default', ['less' , 'less-uncss', 'minJS' , 'watch']);
<commit_msg>updated gulp file<commit_after>// less
var gulp = require('gulp');
var less = require('gulp-less');
var autoprefixer = require('gulp-autoprefixer');
var minifyCSS = require('gulp-minify-css');
var notify = require('gulp-notify');
var rename = require("gulp-rename");
var uncss = require('gulp-uncss');

// js
var gulpConcat = require('gulp-concat');
var uglify = require('gulp-uglify');

// less vars
var lessWatchFolder = './css/less/**/*.less';
var lessFile = './css/less/etherwallet-master.less';
var lessOutputFolder = './css';
var lessOutputFile = 'etherwallet-master.css';
var lessOutputFileMin = 'etherwallet-master.min.css';

var htmlWatchFolder = './*.html';

//js vars
var jsWatchFolder = './js/source/*.js';
var jsFiles = "./js/source/*.js";
var jsOutputFolder = './js';
var jsOutputFile = 'etherwallet-master.min.js';

gulp.task('less', function (cb) {
  return gulp
    .src(lessFile)
      .pipe(less({ compress: false })).on('error', notify.onError(function (error) {
        return "ERROR! Problem file : " + error.message;
      }))
      .pipe(autoprefixer('last 2 version', 'ie 9', 'ios 6', 'android 4'))
      .pipe(rename(lessOutputFile))
      .pipe(gulp.dest(lessOutputFolder))
      .pipe(minifyCSS({keepBreaks: false}))
      .pipe(rename(lessOutputFileMin))
      .pipe(gulp.dest(lessOutputFolder))
      .pipe(notify('Less Compiled and Minified'));
});

gulp.task('less-uncss', ['less'], function () {
  return gulp
    .src('./css/' + lessOutputFile)
      .pipe(uncss({
        html: [
          './index2.html'
        ]
      }))
      .pipe(minifyCSS({keepBreaks: false}))
      .pipe(rename(lessOutputFileMin))
      .pipe(gulp.dest(lessOutputFolder))
    .pipe(notify('Less UnCSS and Minified'));
});

gulp.task('minJS', function () {
  return gulp
    .src(jsFiles)
      .pipe(gulpConcat(jsOutputFile))
      .pipe(uglify())
      .pipe(gulp.dest(jsOutputFolder))
    .pipe(notify('JS Concat and Uglified'));
});

gulp.task('watchJS', function() {
    gulp.watch(jsWatchFolder, ['minJS']);
});
gulp.task('watchLess', function() {
    gulp.watch(lessWatchFolder, ['less' , 'less-uncss']);
});
gulp.task('watchHTML', function() {
    gulp.watch(htmlWatchFolder, ['less-uncss']);
});

gulp.task('default', ['minJS' , 'less', 'less-uncss', 'watchJS' , 'watchLess', 'watchHTML' ]);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var watch = require('gulp-watch');
var mocha = require('gulp-mocha');
var mount = require('mount-routes');

var source_path = ['test/**/*.js', 'lib/*.js'];

gulp.task('watch', function() {
  gulp.watch(source_path, ['mocha']);
});

gulp.task('mocha', function () {
    return gulp.src(source_path , {read: false})
        // gulp-mocha needs filepaths so you can't have any plugins before it
        .pipe(mocha({reporter: 'spec'}));
});

gulp.task('routes', function() {
  var express       = require('express');
  var app           = express();

  // mount routes
  mount(app, __dirname + '/app/routes', true);
});

gulp.task('kp', function() {
  var kp = require("kp");
  var is_sudo = false;
  var pre = is_sudo == true ? 'sudo' : '' ;

  kp(3000, pre);
});

gulp.task('default',['mocha', 'watch']);<commit_msg>refact, please ignore<commit_after>'use strict'

const path = require('path')
const gulp = require('gulp')
const mocha = require('gulp-mocha')
const mount = require('mount-routes')

const sourcePath = ['test/**/*.js', 'lib/*.js']

gulp.task('watch', function () {
  gulp.watch(sourcePath, ['mocha'])
})

gulp.task('mocha', function () {
  return gulp.src(sourcePath, {read: false})
    // gulp-mocha needs filepaths so you can't have any plugins before it
    .pipe(mocha({reporter: 'spec'}))
})

gulp.task('routes', function () {
  let express = require('express')
  let app = express()

  // mount routes
  mount(app, path.join(__dirname, 'app/routes'), true)
})

gulp.task('kp', function () {
  let kp = require('kp')
  let isSudo = false
  let pre = isSudo === true ? 'sudo' : ''

  kp(3000, pre)
})

gulp.task('default', ['mocha', 'watch'])
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp'),
    gutil = require('gulp-util'),
    clean = require('gulp-clean'),
    gulpSequence = require('gulp-sequence'),
    jshint = require('gulp-jshint'),
    concat = require('gulp-concat'),
    rename = require('gulp-rename'),
    uglify = require('gulp-uglify'),
    babel = require('gulp-babel'),
    browserify = require('gulp-browserify'),
    eslint = require('gulp-eslint'),
    version = 'v' + require('./package.json').version;

gulp.task('clean', function () {
    return gulp.src(['dist/*', 'lib/*'])
        .pipe(clean({force: true}));
});

gulp.task('jshint', function () {
    return gulp.src([
        'lib/**/*.js'
    ])
        .pipe(jshint())
        .pipe(jshint.reporter());
});

gulp.task('eslint', function () {
    return gulp.src([
        'src/**/*.js',
        'test/**/*.js'
    ])
        .pipe(eslint({configFle:"./.eslintrc"}))
        .pipe(eslint.format())
        ;
});

gulp.task('es6to5', ['eslint'], function() {
    return gulp.src('./src/**/*.js')
        .pipe(babel())
        .pipe(gulp.dest('./lib/'));
});

gulp.task('pack', ['es6to5'], function() {
    return gulp.src('./lib/index.js')
        .pipe(browserify())
        .pipe(concat('dist/js/jm-core.js'))
        .pipe(gulp.dest(''))
        .pipe(rename({suffix: '.min'}))
        .pipe(uglify())
        .pipe(gulp.dest('')
        );
});

gulp.task('default', gulpSequence('clean', ['pack']));

<commit_msg>gulp doc<commit_after>'use strict';

var gulp = require('gulp'),
    gutil = require('gulp-util'),
    clean = require('gulp-clean'),
    gulpSequence = require('gulp-sequence'),
    jshint = require('gulp-jshint'),
    concat = require('gulp-concat'),
    rename = require('gulp-rename'),
    uglify = require('gulp-uglify'),
    babel = require('gulp-babel'),
    browserify = require('gulp-browserify'),
    eslint = require('gulp-eslint'),
    jsdoc = require('gulp-jsdoc3'),
    version = 'v' + require('./package.json').version
    ;

gulp.task('clean', function () {
    return gulp.src(['dist/*', 'lib/*'])
        .pipe(clean({force: true}));
});

gulp.task('jshint', function () {
    return gulp.src([
        'lib/**/*.js'
    ])
        .pipe(jshint())
        .pipe(jshint.reporter());
});

gulp.task('eslint', function () {
    return gulp.src([
        'src/**/*.js',
        'test/**/*.js'
    ])
        .pipe(eslint({configFle:"./.eslintrc"}))
        .pipe(eslint.format())
        ;
});

gulp.task('es6to5', ['eslint'], function() {
    return gulp.src('./src/**/*.js')
        .pipe(babel())
        .pipe(gulp.dest('./lib/'));
});

gulp.task('pack', ['es6to5'], function() {
    return gulp.src('./lib/index.js')
        .pipe(browserify())
        .pipe(concat('dist/js/jm-core.js'))
        .pipe(gulp.dest(''))
        .pipe(rename({suffix: '.min'}))
        .pipe(uglify())
        .pipe(gulp.dest('')
        );
});

gulp.task('doc', function (cb) {
    gulp.src(['README.md', './src/**/*.js'], {read: false})
        .pipe(jsdoc(cb));
});

gulp.task('default', gulpSequence('clean', ['pack']));

<|endoftext|>


<commit_before>var gulp = require('gulp');
var karma = require('karma').server;
var watch = require('gulp-watch');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var image = require('gulp-image');
var compass = require('gulp-compass');
var minifyCSS = require('gulp-minify-css');
var mocha = require('gulp-mocha');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var rename = require('gulp-rename');
var runSequence = require('run-sequence');
var preprocess = require('gulp-preprocess');

var paths = {
  src: {
    bower: './client/app/src/bower_components',
    js: './client/app/src/js',
    scss: './client/app/src/scss',
    img: './client/app/src/img',
    views: './client/app/src/views'
  },
  dist: {
    js: './client/app/dist/js',
    css: './client/app/dist/css',
    img: './client/app/dist/img',
    views: './client/app/dist/views'
  },
  jade: './server/views/_partials',
  serverSpec: __dirname + '/spec/server/**/*.js',
  karmaConf: __dirname + '/spec/karma.conf.js'
};

var handleError = function(err) {
  console.log(err.toString());
  this.emit('end');
};

var jsFiles = [
  paths.src.bower + '/angular/angular.js',
  paths.src.bower + '/angular-ui-router/release/angular-ui-router.js',
  paths.src.js + '/app.js',
  paths.src.js + '/controllers/*.js',
  paths.src.js + '/directives/*.js',
  paths.src.js + '/services/*.js'
];

// Keep track of own JS files for linting
var jsFilesForLint = [
  paths.src.js + '/**/*.js'
];

var jadeFiles = [paths.jade + '/*.jade'];

/**
 * envConfig, envConfigDevelopment, and envConfigProduction are used to configure builds
 * with the proper environment. Arguments are passed into the preprocess
 * task to insert variables into files. For example, the base href needs
 * to be dynamically set based on the environment.
 */
var envConfig;

var envConfigDevelopment = {
  BASE_HREF: 'localhost:3000'
};

var envConfigProduction = {
  BASE_HREF: 'archivr-dev.herokuapp.com'
};

gulp.task('javascript', function() {
  gulp.src(jsFiles)
  .pipe(concat('app.min.js'))
  // .pipe(uglify({
  //   beautify: true
  // }))
  .on('error', handleError)
  .pipe(gulp.dest(paths.dist.js));
});

/**
 * Run JSHint
 */
gulp.task('lint', function() {
  return gulp.src(jsFilesForLint)
    .pipe(jshint())
    .pipe(jshint.reporter(stylish))
    // Error out if any warnings appear
    .pipe(jshint.reporter('fail'));
});

gulp.task('image', function() {
   gulp.src(paths.src.img + '/**/*')
    .pipe(image())
    .on('error', handleError)
    .pipe(gulp.dest(paths.dist.img));
});

gulp.task('moveViews', function() {
  gulp.src(paths.src.views + '/**/*')
    .pipe(gulp.dest(paths.dist.views));
});

gulp.task('compass', function() {
  gulp.src(paths.src.scss + '/*.scss')
    .pipe(compass({
      css: paths.dist.css,
      sass: paths.src.scss,
      image: paths.dist.img,
      require: ['breakpoint']
    }))
    .on('error', handleError)
    .pipe(minifyCSS())
    .pipe(concat('app.css'))
    .pipe(gulp.dest(paths.dist.css));
});

gulp.task('processEnv', function() {
  gulp.src(jadeFiles)
    .pipe(preprocess({context: envConfig}))
    .pipe(gulp.dest(paths.jade + '/dist'));
});

gulp.task('karma', function (done) {
  return karma.start({
    configFile: paths.karmaConf,
    singleRun: true
  }, done);
});

gulp.task('mocha', function () {
  return gulp.src(paths.serverSpec, {read: false})
    .pipe(mocha({
      reporter: 'spec',
    }))
    /**
     * The methods below are a hack to get gulp to exit after mocha tests
     * finish. Without these methods, you must ^+C to exit, and Travis will
     * never finish running the tests.
     *
     * However, it suppresses error messages from mocha (e.g. server
     * errors that cause the process to crash). If the tests are not running
     * or Travis is behaving strangely, comment out these methods to report
     * the errors and debug.
     */
    .once('error', function () {
        process.exit(1);
    })
    .once('end', function () {
      process.exit();
    });
});

gulp.task('watch', function() {
  gulp.watch(paths.src.img + '/**/*', ['image']);
  gulp.watch(paths.src.scss + '/**/*.scss', ['compass']);
  gulp.watch(paths.src.js + '/**/*.js', ['lint', 'javascript']);
  gulp.watch(paths.src.views + '/**/*', ['moveViews']);
});

// Run testing suite: lint, karma (client-side) and mocha (server-side)
gulp.task('test', function(callback) {
  /**
   * Use `runSequence` to call tasks synchronously, otherwise
   * messages from both will be potentially interleaved.
   */
  runSequence('lint', 'karma', 'mocha', callback);
});

/**
 * build-development and build-production tasks are to build out the app with different
 * configurations. Preprocessing is necessary to insert the appropriate
 * base href into the Jade partials.
 */
gulp.task('build-development', function() {
  envConfig = envConfigDevelopment;
  gulp.start('compass', 'image', 'moveViews', 'lint', 'javascript', 'processEnv');
});

gulp.task('build-production', function() {
  envConfig = envConfigProduction;
  gulp.start('compass', 'image', 'moveViews', 'lint', 'javascript', 'processEnv');
});

gulp.task('default', ['build-development', 'watch']);
<commit_msg>add extended timeout to mocha<commit_after>var gulp = require('gulp');
var karma = require('karma').server;
var watch = require('gulp-watch');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var image = require('gulp-image');
var compass = require('gulp-compass');
var minifyCSS = require('gulp-minify-css');
var mocha = require('gulp-mocha');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var rename = require('gulp-rename');
var runSequence = require('run-sequence');
var preprocess = require('gulp-preprocess');

var paths = {
  src: {
    bower: './client/app/src/bower_components',
    js: './client/app/src/js',
    scss: './client/app/src/scss',
    img: './client/app/src/img',
    views: './client/app/src/views'
  },
  dist: {
    js: './client/app/dist/js',
    css: './client/app/dist/css',
    img: './client/app/dist/img',
    views: './client/app/dist/views'
  },
  jade: './server/views/_partials',
  serverSpec: __dirname + '/spec/server/**/*.js',
  karmaConf: __dirname + '/spec/karma.conf.js'
};

var handleError = function(err) {
  console.log(err.toString());
  this.emit('end');
};

var jsFiles = [
  paths.src.bower + '/angular/angular.js',
  paths.src.bower + '/angular-ui-router/release/angular-ui-router.js',
  paths.src.js + '/app.js',
  paths.src.js + '/controllers/*.js',
  paths.src.js + '/directives/*.js',
  paths.src.js + '/services/*.js'
];

// Keep track of own JS files for linting
var jsFilesForLint = [
  paths.src.js + '/**/*.js'
];

var jadeFiles = [paths.jade + '/*.jade'];

/**
 * envConfig, envConfigDevelopment, and envConfigProduction are used to configure builds
 * with the proper environment. Arguments are passed into the preprocess
 * task to insert variables into files. For example, the base href needs
 * to be dynamically set based on the environment.
 */
var envConfig;

var envConfigDevelopment = {
  BASE_HREF: 'localhost:3000'
};

var envConfigProduction = {
  BASE_HREF: 'archivr-dev.herokuapp.com'
};

gulp.task('javascript', function() {
  gulp.src(jsFiles)
  .pipe(concat('app.min.js'))
  // .pipe(uglify({
  //   beautify: true
  // }))
  .on('error', handleError)
  .pipe(gulp.dest(paths.dist.js));
});

/**
 * Run JSHint
 */
gulp.task('lint', function() {
  return gulp.src(jsFilesForLint)
    .pipe(jshint())
    .pipe(jshint.reporter(stylish))
    // Error out if any warnings appear
    .pipe(jshint.reporter('fail'));
});

gulp.task('image', function() {
   gulp.src(paths.src.img + '/**/*')
    .pipe(image())
    .on('error', handleError)
    .pipe(gulp.dest(paths.dist.img));
});

gulp.task('moveViews', function() {
  gulp.src(paths.src.views + '/**/*')
    .pipe(gulp.dest(paths.dist.views));
});

gulp.task('compass', function() {
  gulp.src(paths.src.scss + '/*.scss')
    .pipe(compass({
      css: paths.dist.css,
      sass: paths.src.scss,
      image: paths.dist.img,
      require: ['breakpoint']
    }))
    .on('error', handleError)
    .pipe(minifyCSS())
    .pipe(concat('app.css'))
    .pipe(gulp.dest(paths.dist.css));
});

gulp.task('processEnv', function() {
  gulp.src(jadeFiles)
    .pipe(preprocess({context: envConfig}))
    .pipe(gulp.dest(paths.jade + '/dist'));
});

gulp.task('karma', function (done) {
  return karma.start({
    configFile: paths.karmaConf,
    singleRun: true
  }, done);
});

gulp.task('mocha', function () {
  return gulp.src(paths.serverSpec, {read: false})
    .pipe(mocha({
      reporter: 'spec',
      timeout: 10000
    }))
    /**
     * The methods below are a hack to get gulp to exit after mocha tests
     * finish. Without these methods, you must ^+C to exit, and Travis will
     * never finish running the tests.
     *
     * However, it suppresses error messages from mocha (e.g. server
     * errors that cause the process to crash). If the tests are not running
     * or Travis is behaving strangely, comment out these methods to report
     * the errors and debug.
     */
    .once('error', function () {
        process.exit(1);
    })
    .once('end', function () {
      process.exit();
    });
});

gulp.task('watch', function() {
  gulp.watch(paths.src.img + '/**/*', ['image']);
  gulp.watch(paths.src.scss + '/**/*.scss', ['compass']);
  gulp.watch(paths.src.js + '/**/*.js', ['lint', 'javascript']);
  gulp.watch(paths.src.views + '/**/*', ['moveViews']);
});

// Run testing suite: lint, karma (client-side) and mocha (server-side)
gulp.task('test', function(callback) {
  /**
   * Use `runSequence` to call tasks synchronously, otherwise
   * messages from both will be potentially interleaved.
   */
  runSequence('lint', 'karma', 'mocha', callback);
});

/**
 * build-development and build-production tasks are to build out the app with different
 * configurations. Preprocessing is necessary to insert the appropriate
 * base href into the Jade partials.
 */
gulp.task('build-development', function() {
  envConfig = envConfigDevelopment;
  gulp.start('compass', 'image', 'moveViews', 'lint', 'javascript', 'processEnv');
});

gulp.task('build-production', function() {
  envConfig = envConfigProduction;
  gulp.start('compass', 'image', 'moveViews', 'lint', 'javascript', 'processEnv');
});

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


<commit_before>var gulp = require('gulp'),
    sass = require('gulp-sass'),
    sourcemaps = require('gulp-sourcemaps'),
    autoprefixer = require('gulp-autoprefixer'),
    fileinclude = require("gulp-file-include"),
    minify = require('gulp-minify'),
    rename = require('gulp-rename'),
    concat = require('gulp-concat'),
    concatCss = require('gulp-concat-css');

var input = "app/src/scss/*.scss";
var output = "app/dist/css/";

var sassOptions = {
  errLogToConsole: false,
  outputStyle: 'expanded'
};

gulp.task('css', function() {
    return sass(config.sassPath + output, {
            style: 'compressed',
            loadPath: [
                './app/scss',
                config.bowerDir + '/bootstrap-sass/assets/stylesheets',
                config.bowerDir + '/fontawesome/scss',
            ]
        })
        .pipe(gulp.dest('./app/css'));
});

gulp.task('sass', function() {
  return gulp
    .src(input)
    .pipe(sourcemaps.init())
    .pipe(sass(sassOptions).on('error', sass.logError))
    .pipe(autoprefixer())
    .pipe(sourcemaps.write('./stylesheets/maps'))
    .pipe(gulp.dest(output));
});

gulp.task('compress_js', function() {
  gulp.src('app/src/js/*.js')
    .pipe(rename({
      suffix: '.min'
    }))
    .pipe(minify({
        ext:{
            src:'-debug.js',
            min:'.js'
        },
        exclude: ['tasks'],
        ignoreFiles: ['.combo.js', '-min.js']
    }))

    .pipe(gulp.dest('app/dist/js/'))
});

gulp.task('compress_controllers_js', function() {
  gulp.src('app/src/js/controllers/*.js')
    .pipe(rename({
      suffix: '.min'
    }))
    .pipe(minify({
        ext:{
            src:'-debug.js',
            min:'.js'
        },
        exclude: ['tasks'],
        ignoreFiles: ['.combo.js', '-min.js']
    }))

    .pipe(gulp.dest('app/dist/js/controllers'))
});

gulp.task('compress_services_js', function() {
  gulp.src('app/src/js/services/*.js')
    .pipe(rename({
      suffix: '.min'
    }))
    .pipe(minify({
        exclude: ['tasks'],
        ignoreFiles: ['.combo.js', '-min.js']
    }))

    .pipe(gulp.dest('app/dist/js/services'))
});
// gulp.task('fileinclude', function() {
//   gulp.src('app/source/*.html')
//     .pipe(fileinclude({
//       prefix: '@@',
//       basepath: '@file'
//     }))
//     .pipe(gulp.dest('./app/views/'));
// });

gulp.task('watch', function() {
  return gulp
    // Watch the input folder for change,
    // and run `sass` task when something happens
    .watch(input, ['sass'])
    // When there is a change,
    // log a message in the console
    .on('change', function(event) {
      console.log('File ' + event.path + ' was ' + event.type + ', Corriendo tareas... Amando a los animales <3');
    });
});

gulp.task('scripts', function() {
  return gulp.src(['app/dist/**/*.js', '!app/dist/**/*.min-debug.js'])
    .pipe(concat('alljavascript.js'))
    .pipe(gulp.dest('app/'));
});

gulp.task('styles', function() {
  return gulp.src(['app/bower_components/angular-bootstrap/ui-bootstrap-csp.css', 'app/bower_components/components-font-awesome/css/font-awesome.css', 'app/bower_components/flexslider/flexslider.css', 'app/dist/css/stylesheet.css', 'app/bower_components/sweetalert2/dist/sweetalert2.css'])
    .pipe(concatCss('allstyles.css'))
    .pipe(gulp.dest('app/'));
});

gulp.task('default', ['sass', 'watch', 'compress_js', 'compress_controllers_js', 'compress_services_js', 'scripts', 'styles']);
<commit_msg>Added -debug.js exeption<commit_after>var gulp = require('gulp'),
    sass = require('gulp-sass'),
    sourcemaps = require('gulp-sourcemaps'),
    autoprefixer = require('gulp-autoprefixer'),
    fileinclude = require("gulp-file-include"),
    minify = require('gulp-minify'),
    rename = require('gulp-rename'),
    concat = require('gulp-concat'),
    concatCss = require('gulp-concat-css');

var input = "app/src/scss/*.scss";
var output = "app/dist/css/";

var sassOptions = {
  errLogToConsole: false,
  outputStyle: 'expanded'
};

gulp.task('css', function() {
    return sass(config.sassPath + output, {
            style: 'compressed',
            loadPath: [
                './app/scss',
                config.bowerDir + '/bootstrap-sass/assets/stylesheets',
                config.bowerDir + '/fontawesome/scss',
            ]
        })
        .pipe(gulp.dest('./app/css'));
});

gulp.task('sass', function() {
  return gulp
    .src(input)
    .pipe(sourcemaps.init())
    .pipe(sass(sassOptions).on('error', sass.logError))
    .pipe(autoprefixer())
    .pipe(sourcemaps.write('./stylesheets/maps'))
    .pipe(gulp.dest(output));
});

gulp.task('compress_js', function() {
  gulp.src('app/src/js/*.js')
    .pipe(rename({
      suffix: '.min'
    }))
    .pipe(minify({
        ext:{
            src:'-debug.js',
            min:'.js'
        },
        exclude: ['tasks'],
        ignoreFiles: ['.combo.js', '-min.js']
    }))

    .pipe(gulp.dest('app/dist/js/'))
});

gulp.task('compress_controllers_js', function() {
  gulp.src('app/src/js/controllers/*.js')
    .pipe(rename({
      suffix: '.min'
    }))
    .pipe(minify({
        ext:{
            src:'-debug.js',
            min:'.js'
        },
        exclude: ['tasks'],
        ignoreFiles: ['.combo.js', '-min.js']
    }))

    .pipe(gulp.dest('app/dist/js/controllers'))
});

gulp.task('compress_services_js', function() {
  gulp.src('app/src/js/services/*.js')
    .pipe(rename({
      suffix: '.min'
    }))
    .pipe(minify({
        ext:{
            src:'-debug.js',
            min:'.js'
        },
        exclude: ['tasks'],
        ignoreFiles: ['.combo.js', '-min.js']
    }))

    .pipe(gulp.dest('app/dist/js/services'))
});
// gulp.task('fileinclude', function() {
//   gulp.src('app/source/*.html')
//     .pipe(fileinclude({
//       prefix: '@@',
//       basepath: '@file'
//     }))
//     .pipe(gulp.dest('./app/views/'));
// });

gulp.task('watch', function() {
  return gulp
    // Watch the input folder for change,
    // and run `sass` task when something happens
    .watch(input, ['sass'])
    // When there is a change,
    // log a message in the console
    .on('change', function(event) {
      console.log('File ' + event.path + ' was ' + event.type + ', Corriendo tareas... Amando a los animales <3');
    });
});

gulp.task('scripts', function() {
  return gulp.src(['app/dist/**/*.js', '!app/dist/**/*.min-debug.js'])
    .pipe(concat('alljavascript.js'))
    .pipe(gulp.dest('app/'));
});

gulp.task('styles', function() {
  return gulp.src(['app/bower_components/angular-bootstrap/ui-bootstrap-csp.css', 'app/bower_components/components-font-awesome/css/font-awesome.css', 'app/bower_components/flexslider/flexslider.css', 'app/dist/css/stylesheet.css', 'app/bower_components/sweetalert2/dist/sweetalert2.css'])
    .pipe(concatCss('allstyles.css'))
    .pipe(gulp.dest('app/'));
});

gulp.task('default', ['sass', 'watch', 'compress_js', 'compress_controllers_js', 'compress_services_js', 'scripts', 'styles']);
<|endoftext|>


<commit_before>// Include gulp
var gulp = require('gulp');

// Include Our Plugins
var rimraf = require('gulp-rimraf');
var jshint = require('gulp-jshint');
var closure = require('gulp-closure-compiler');
var browserify = require('gulp-browserify');
var jsdoc = require('gulp-jsdoc');
var mochaPhantomJS = require('gulp-mocha-phantomjs');
var generateSuite = require("gulp-mocha-browserify-suite");

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

gulp.task('check', function(){
    // Perform type checking, etc. with closure compiler
    gulp.src('build/linearalgea.js')
        .pipe(closure({
            compilerPath: '/usr/share/java/closure-compiler/closure-compiler.jar',
            fileName: 'linearalgea.min.js',
            compilerFlags: {
                warning_level: 'VERBOSE',
                summary_detail_level: 1
            }
        }))
});

// Compress/minify
gulp.task('compress', function(){
    gulp.src('build/linearalgea.js')
        .pipe(closure({
            compilerPath: '/usr/share/java/closure-compiler/closure-compiler.jar',
            fileName: 'linearalgea.min.js',
            compilerFlags: {
                warning_level: 'QUIET',
                compilation_level: 'SIMPLE_OPTIMIZATIONS'
            }
        }))
        .pipe(gulp.dest('build'));
});

gulp.task('browserify', function() {
    gulp.src('src/linearalgea.js')
        .pipe(browserify({
            standalone: 'linearalgea'
        }))
        .pipe(gulp.dest('build'));
});

// Build documentation
gulp.task('docs', ['cleandocs'], function() {
    gulp.src('src/**/*.js')
        .pipe(jsdoc('docs'));
});

gulp.task('watch', function() {
    gulp.watch('src/**/*.{js,html}', ['lint', 'browserify']);
});

gulp.task('cleantests', function() {
  return gulp.src('tests/build/suite.js', { read: false })
    .pipe(rimraf());
});

gulp.task('cleandocs', function() {
  return gulp.src('docs/*', { read: false })
    .pipe(rimraf());
});

gulp.task('browserify-tests', ['cleantests'], function() {
    return gulp.src('tests/**/*.js')
        .pipe(generateSuite())
        .pipe(browserify({
            standalone: 'tests',
            debug: true
        }))
        .pipe(gulp.dest('tests/build'));
});

gulp.task('mocha-phantom', ['browserify-tests'], function() {
    return gulp.src('tests/testrunner.html').pipe(mochaPhantomJS({ reporter: 'min', ui: 'tdd'}));
});

// Default Task
gulp.task('default', ['lint', 'browserify', 'watch']);
gulp.task('compile', ['browserify', 'compress']);
gulp.task('check', ['lint', 'browserify', 'check']);
gulp.task('test', function(){
    gulp.watch(['tests/**/*.{js,html}', '!tests/build/*'], ['mocha-phantom']);
});
<commit_msg>Fix gulpfile check method<commit_after>// Include gulp
var gulp = require('gulp');

// Include Our Plugins
var rimraf = require('gulp-rimraf');
var jshint = require('gulp-jshint');
var closure = require('gulp-closure-compiler');
var browserify = require('gulp-browserify');
var jsdoc = require('gulp-jsdoc');
var mochaPhantomJS = require('gulp-mocha-phantomjs');
var generateSuite = require("gulp-mocha-browserify-suite");

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

gulp.task('closure-compiler', function(){
    // Perform type checking, etc. with closure compiler
    gulp.src('build/linearalgea.js')
        .pipe(closure({
            compilerPath: '/usr/share/java/closure-compiler/closure-compiler.jar',
            fileName: 'linearalgea.min.js',
            compilerFlags: {
                warning_level: 'VERBOSE',
                summary_detail_level: 1
            }
        }))
});

// Compress/minify
gulp.task('compress', function(){
    gulp.src('build/linearalgea.js')
        .pipe(closure({
            compilerPath: '/usr/share/java/closure-compiler/closure-compiler.jar',
            fileName: 'linearalgea.min.js',
            compilerFlags: {
                warning_level: 'QUIET',
                compilation_level: 'SIMPLE_OPTIMIZATIONS'
            }
        }))
        .pipe(gulp.dest('build'));
});

gulp.task('browserify', function() {
    gulp.src('src/linearalgea.js')
        .pipe(browserify({
            standalone: 'linearalgea'
        }))
        .pipe(gulp.dest('build'));
});

// Build documentation
gulp.task('docs', ['cleandocs'], function() {
    gulp.src('src/**/*.js')
        .pipe(jsdoc('docs'));
});

gulp.task('watch', function() {
    gulp.watch('src/**/*.{js,html}', ['lint', 'browserify']);
});

gulp.task('cleantests', function() {
  return gulp.src('tests/build/suite.js', { read: false })
    .pipe(rimraf());
});

gulp.task('cleandocs', function() {
  return gulp.src('docs/*', { read: false })
    .pipe(rimraf());
});

gulp.task('browserify-tests', ['cleantests'], function() {
    return gulp.src('tests/**/*.js')
        .pipe(generateSuite())
        .pipe(browserify({
            standalone: 'tests',
            debug: true
        }))
        .pipe(gulp.dest('tests/build'));
});

gulp.task('mocha-phantom', ['browserify-tests'], function() {
    return gulp.src('tests/testrunner.html').pipe(mochaPhantomJS({ reporter: 'min', ui: 'tdd'}));
});

// Default Task
gulp.task('default', ['lint', 'browserify', 'watch']);
gulp.task('compile', ['browserify', 'compress']);
gulp.task('check', ['lint', 'browserify', 'closure-compiler']);
gulp.task('test', function(){
    gulp.watch(['tests/**/*.{js,html}', '!tests/build/*'], ['mocha-phantom']);
});
<|endoftext|>


<commit_before>(function(gulp, gulpLoadPlugins){
	var $ = gulpLoadPlugins({
			    pattern: '*',
			    lazy: true
				}),
			_ = {
				app:  'app',
        dist: 'dist',
        sass: 'app/sass',
        tmpl: 'app/src',
        js:   'app/js',
        css:  'app/css',
        img:  'app/img'
			},
			files = [
		    'app/*.html',
		    'app/css/**/*.css',
		    'app/img/**/*',
		    'app/js/**/*.js'
		  ];

	// 处理错误
	function handleError(error){
    console.log(error.message);
    this.emit('end');
  }

  // gulp-jshint
  // js代码校验
  gulp.task('jshint', function() {
    return gulp.src([ 'gulpfile.js' , _.js + '/**/*.js'])
      .pipe($.jshint())
      .pipe($.jshint.reporter('jshint-stylish'));
  });

  // gulp-scss-lint
  // scss校验
  gulp.task('scss-lint', function() {
    return gulp.src([_.sass + '/**/*.{scss, sass}'])
      .pipe($.scssLint({
        'config': '.scsslintrc',
        'customReport': $.scssLintStylish
      }));
  });

	// gulp-sass, gulp-autoprefixer, gulp-sourcemaps
	// 将sass预处理为css，
	// 使用autoprefixer来补全浏览器兼容的css
	// 使用sourcemaps 检查错误
	gulp.task('sass', function(){
		return gulp.src(_.sass + '/*.scss')
			.pipe($.plumber({ errorHandler: handleError}))
			.pipe($.sourcemaps.init())
			.pipe($.autoprefixer({
				browers: ['last 2 versions','safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4']
			}))
			.pipe($.sass({
        outputStyle: 'expanded',
        includePaths: [ './bower_components/' ]
      }))
			.pipe($.sourcemaps.write('./'))
			.pipe(gulp.dest(_.css))
			.pipe($.size({
        title: 'CSS files:'
      }));
	});

  // 渲染html文件模板
  // 使用gulp-file-include合并模板文件
  gulp.task('html', function() {
    return gulp.src([_.tmpl + '/*.html'])
      .pipe($.plumber())
      .pipe($.fileInclude({
        prefix: '@@',
        basepath: '@file'
      }))
      .pipe(gulp.dest(_.app + '/'))
      .pipe($.size({
        title: 'HTML files:'
      }));
  });

	// browser-sync
  // 实时将修改信息渲染到浏览器
  gulp.task('browser-sync', function(){
  	$.browserSync.init(files,{
  		server: {
  			baseDir: './app'
  		},
  		port: 9000
  	});
  });

  // 监听修改信息
	gulp.task('watch', function(){
		// 监听css修改
		$.watch([_.sass + '/*.scss'], function(){
			gulp.start('sass');
		});
		// 监听html修改
		$.watch([_.tmpl + '/**/*.html'], function(){
			gulp.start('html');
		});
		gulp.start('browser-sync');
	});

	// 上面是开发环境，下面是打包上线

	// 图片压缩
	gulp.task('image', function(){
		return gulp.src(_.img + '/**/*')
			.pipe($.cache($.imagemin({ optimizationLevel: 3, progressive: true, interlaced: true })))
			.pipe($.imagemin({
				pregressive: true,
				svgoPlugins: [{removeViewBox: false}],
				use: [$.imageminPngquant()]
			}))
			.pipe(gulp.dest(_.dist + '/img'))
			.pipe($.size({
				title: 'IMAGE files:'
			}));
	});

	// js、css、html压缩处理（可选）
	// 打包到dist文件夹下
	gulp.task('dist', function(){
		return gulp.src('app/*.html')
			.pipe($.plumber())
			.pipe($.useref())
			.pipe($.if('*.js', $.uglify()))
			.pipe($.if('*.css', $.cssnano()))
			.pipe(gulp.dest(_.dist));
	});

	// 删除dist文件夹
	gulp.task('rimraf', function(){
		return gulp.src(_.dist + '*', {read: false})
			.pipe($.rimraf({force: true}));
	});

	// gulp-start
	// 启动项目
	gulp.task('start', ['watch']);
	// 检查css和js
  gulp.task('test',  ['jshint', 'scss-lint']);
	// 默认
	gulp.task('default', ['html', 'sass', 'rimraf'], function(){
		gulp.start(['image', 'dist']);
	});
})(require('gulp'), require('gulp-load-plugins'));<commit_msg>master: 完善gulp start<commit_after>(function(gulp, gulpLoadPlugins){
	var $ = gulpLoadPlugins({
			    pattern: '*',
			    lazy: true
				}),
			_ = {
				app:  'app',
        dist: 'dist',
        sass: 'app/sass',
        tmpl: 'app/src',
        js:   'app/js',
        css:  'app/css',
        img:  'app/img'
			},
			files = [
		    'app/*.html',
		    'app/css/**/*.css',
		    'app/img/**/*',
		    'app/js/**/*.js'
		  ];

	// 处理错误
	function handleError(error){
    console.log(error.message);
    this.emit('end');
  }

  // gulp-jshint
  // js代码校验
  gulp.task('jshint', function() {
    return gulp.src([ 'gulpfile.js' , _.js + '/**/*.js'])
      .pipe($.jshint())
      .pipe($.jshint.reporter('jshint-stylish'));
  });

  // gulp-scss-lint
  // scss校验
  gulp.task('scss-lint', function() {
    return gulp.src([_.sass + '/**/*.{scss, sass}'])
      .pipe($.scssLint({
        'config': '.scsslintrc',
        'customReport': $.scssLintStylish
      }));
  });

	// gulp-sass, gulp-autoprefixer, gulp-sourcemaps
	// 将sass预处理为css，
	// 使用autoprefixer来补全浏览器兼容的css
	// 使用sourcemaps 检查错误
	gulp.task('sass', function(){
		return gulp.src(_.sass + '/*.scss')
			.pipe($.plumber({ errorHandler: handleError}))
			.pipe($.sourcemaps.init())
			.pipe($.autoprefixer({
				browers: ['last 2 versions','safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4']
			}))
			.pipe($.sass({
        outputStyle: 'expanded',
        includePaths: [ './bower_components/' ]
      }))
			.pipe($.sourcemaps.write('./'))
			.pipe(gulp.dest(_.css))
			.pipe($.size({
        title: 'CSS files:'
      }));
	});

  // 渲染html文件模板
  // 使用gulp-file-include合并模板文件
  gulp.task('html', function() {
    return gulp.src([_.tmpl + '/*.html'])
      .pipe($.plumber())
      .pipe($.fileInclude({
        prefix: '@@',
        basepath: '@file'
      }))
      .pipe(gulp.dest(_.app + '/'))
      .pipe($.size({
        title: 'HTML files:'
      }));
  });

	// browser-sync
  // 实时将修改信息渲染到浏览器
  gulp.task('browser-sync', function(){
  	$.browserSync.init(files,{
  		server: {
  			baseDir: './app'
  		},
  		port: 9000
  	});
  });

  // 监听修改信息
	gulp.task('watch', function(){
		// 监听css修改
		$.watch([_.sass + '/*.scss'], function(){
			gulp.start('sass');
		});
		// 监听html修改
		$.watch([_.tmpl + '/**/*.html'], function(){
			gulp.start('html');
		});
		gulp.start('browser-sync');
	});

	// 上面是开发环境，下面是打包上线

	// 图片压缩
	gulp.task('image', function(){
		return gulp.src(_.img + '/**/*')
			.pipe($.cache($.imagemin({ optimizationLevel: 3, progressive: true, interlaced: true })))
			.pipe($.imagemin({
				pregressive: true,
				svgoPlugins: [{removeViewBox: false}],
				use: [$.imageminPngquant()]
			}))
			.pipe(gulp.dest(_.dist + '/img'))
			.pipe($.size({
				title: 'IMAGE files:'
			}));
	});

	// js、css、html压缩处理（可选）
	// 打包到dist文件夹下
	gulp.task('dist', function(){
		return gulp.src('app/*.html')
			.pipe($.plumber())
			.pipe($.useref())
			.pipe($.if('*.js', $.uglify()))
			.pipe($.if('*.css', $.cssnano()))
			.pipe(gulp.dest(_.dist));
	});

	// 删除dist文件夹
	gulp.task('rimraf', function(){
		return gulp.src(_.dist + '*', {read: false})
			.pipe($.rimraf({force: true}));
	});

	// gulp-start
	// 启动项目
	gulp.task('start', ['watch', 'html', 'sass']);
	// 检查css和js
  gulp.task('test',  ['jshint', 'scss-lint']);
	// 默认
	gulp.task('default', ['html', 'sass', 'rimraf'], function(){
		gulp.start(['image', 'dist']);
	});
})(require('gulp'), require('gulp-load-plugins'));<|endoftext|>


<commit_before>/*
  AMDClean Build File
*/
var gulp = require('gulp'),
  uglify = require('gulp-uglify'),
  jshint = require('gulp-jshint'),
  jasmine = require('gulp-jasmine'),
  rename = require('gulp-rename'),
  insert = require('gulp-insert'),
  requirejs = require('requirejs'),
  fs = require('fs'),
  amdclean = require('./build/amdclean'),
  packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8')),
  licenseText = '\n\n/*' + fs.readFileSync('./LICENSE.txt', 'utf8') + '\n*/\n\n',
  currentDate = (function() {
    var today = new Date(),
      dd = today.getDate(),
      mm = today.getMonth() + 1,
      yyyy = today.getFullYear();

    if (dd < 10) {
      dd = '0' + dd
    }

    if (mm < 10) {
      mm = '0' + mm
    }

    today = yyyy + '-' + mm + '-' + dd;
    return today;
  }()),
  currentYear = (function() {
    var today = new Date(),
      yyyy = today.getFullYear();

    return yyyy;
  }()),
  headerText = '/*! amdclean - v' + packageJson.version + ' - ' + currentDate +
  '\n* http://gregfranko.com/amdclean' +
  '\n* Copyright (c) ' + currentYear + ' Greg Franko */\n',
  error = false,
  cachedBuiltLibText = fs.readFileSync('./src/amdclean.js', 'utf8');
  revertFile = function() {
    fs.writeFileSync('./src/amdclean.js', cachedBuiltLibText);
  };

gulp.task('build', function(cb) {
  requirejs.optimize({
    'findNestedDependencies': false,
    'baseUrl': './src/modules/',
    'optimize': 'none',
    'paths': {
      'amdclean': 'index'
    },
    'include': ['amdclean'],
    'out': './src/amdclean.js',
    'onModuleBundleComplete': function(data) {
      var outputFile = data.path,
        cleanedCode = (function() {
          try {
            return amdclean.clean({
              'filePath': outputFile,
              'transformAMDChecks': false,
              'aggressiveOptimizations': true,
              'ignoreModules': ['esprima', 'estraverse', 'escodegen', 'lodash', 'fs', 'sourcemap_to_ast'], // wtf? parsed name here?
              'removeUseStricts': false,
              'wrap': {
                // All of the third party dependencies are hoisted here
                // It's a hack, but it's not too painful
                'start': ';(function(esprima, estraverse, escodegen, _) {\n',
                'end': '}(typeof esprima !== "undefined" ? esprima: null, typeof estraverse !== "undefined" ? estraverse: null, typeof escodegen !== "undefined" ? escodegen: null, typeof _ !== "undefined" ? _ : null));'
              },
              'createAnonymousAMDModule': true
            });
          } catch (e) {
            error = true;
            revertFile();
            return '' + e;
          }
        }()),
        fullCode = headerText + licenseText + cleanedCode;

      if (error) {
        revertFile();
        console.log('Looks like there was an error building, stopping the build... ' + cleanedCode);
        return;
      }
      fs.writeFileSync(outputFile, fullCode);
    }
  }, function() {
    if (!error) {
      cb();
    }
  }, function(err) {
    revertFile();
    console.log('Looks like there was an error building, stopping the build... ');
    return cb(err); // return error
  });
});

gulp.task('lint', ['build'], function() {
  gulp.src('src/amdclean.js')
    .pipe(jshint({
      'evil': true,
      'loopfunc': true
    }))
    .pipe(jshint.reporter('default'));
});

gulp.task('test', ['build', 'lint'], function() {
  gulp.src('test/specs/convert.js')
    .pipe(jasmine());
});

gulp.task('test-only', function() {
  gulp.src('test/specs/convert.js')
    .pipe(jasmine());
});

gulp.task('minify', ['build', 'lint', 'test'], function() {
  gulp.src(['src/amdclean.js'])
    .pipe(gulp.dest('build/'))
    .pipe(uglify())
    .pipe(insert.prepend(headerText + licenseText))
    .pipe(rename('amdclean.min.js'))
    .pipe(gulp.dest('build/'));
});

// The default task (called when you run `gulp`)
gulp.task('default', ['build', 'lint', 'test', 'minify']);

// The watch task that runs the default task on any AMDclean module file changes
gulp.task('watch', function() {
  var watcher = gulp.watch('src/modules/*.js', ['default']);

  watcher.on('change', function(event) {
    console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
  });
});<commit_msg>Fix so sourcemapToAst is declared before it is initialized, crucial for strict mode.<commit_after>/*
  AMDClean Build File
*/
var gulp = require('gulp'),
  uglify = require('gulp-uglify'),
  jshint = require('gulp-jshint'),
  jasmine = require('gulp-jasmine'),
  rename = require('gulp-rename'),
  insert = require('gulp-insert'),
  requirejs = require('requirejs'),
  fs = require('fs'),
  amdclean = require('./build/amdclean'),
  packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8')),
  licenseText = '\n\n/*' + fs.readFileSync('./LICENSE.txt', 'utf8') + '\n*/\n\n',
  currentDate = (function() {
    var today = new Date(),
      dd = today.getDate(),
      mm = today.getMonth() + 1,
      yyyy = today.getFullYear();

    if (dd < 10) {
      dd = '0' + dd
    }

    if (mm < 10) {
      mm = '0' + mm
    }

    today = yyyy + '-' + mm + '-' + dd;
    return today;
  }()),
  currentYear = (function() {
    var today = new Date(),
      yyyy = today.getFullYear();

    return yyyy;
  }()),
  headerText = '/*! amdclean - v' + packageJson.version + ' - ' + currentDate +
  '\n* http://gregfranko.com/amdclean' +
  '\n* Copyright (c) ' + currentYear + ' Greg Franko */\n',
  error = false,
  cachedBuiltLibText = fs.readFileSync('./src/amdclean.js', 'utf8');
  revertFile = function() {
    fs.writeFileSync('./src/amdclean.js', cachedBuiltLibText);
  };

gulp.task('build', function(cb) {
  requirejs.optimize({
    'findNestedDependencies': false,
    'baseUrl': './src/modules/',
    'optimize': 'none',
    'paths': {
      'amdclean': 'index'
    },
    'include': ['amdclean'],
    'out': './src/amdclean.js',
    'onModuleBundleComplete': function(data) {
      var outputFile = data.path,
        cleanedCode = (function() {
          try {
            return amdclean.clean({
              'filePath': outputFile,
              'transformAMDChecks': false,
              'aggressiveOptimizations': true,
              'ignoreModules': ['esprima', 'estraverse', 'escodegen', 'lodash', 'fs', 'sourcemap_to_ast'], // wtf? parsed name here?
              'removeUseStricts': false,
              'wrap': {
                // All of the third party dependencies are hoisted here
                // It's a hack, but it's not too painful
                'start': ';var sourcemapToAst;(function(esprima, estraverse, escodegen, _) {\n',
                'end': '}(typeof esprima !== "undefined" ? esprima: null, typeof estraverse !== "undefined" ? estraverse: null, typeof escodegen !== "undefined" ? escodegen: null, typeof _ !== "undefined" ? _ : null));'
              },
              'createAnonymousAMDModule': true
            });
          } catch (e) {
            error = true;
            revertFile();
            return '' + e;
          }
        }()),
        fullCode = headerText + licenseText + cleanedCode;

      if (error) {
        revertFile();
        console.log('Looks like there was an error building, stopping the build... ' + cleanedCode);
        return;
      }
      fs.writeFileSync(outputFile, fullCode);
    }
  }, function() {
    if (!error) {
      cb();
    }
  }, function(err) {
    revertFile();
    console.log('Looks like there was an error building, stopping the build... ');
    return cb(err); // return error
  });
});

gulp.task('lint', ['build'], function() {
  gulp.src('src/amdclean.js')
    .pipe(jshint({
      'evil': true,
      'loopfunc': true
    }))
    .pipe(jshint.reporter('default'));
});

gulp.task('test', ['build', 'lint'], function() {
  gulp.src('test/specs/convert.js')
    .pipe(jasmine());
});

gulp.task('test-only', function() {
  gulp.src('test/specs/convert.js')
    .pipe(jasmine());
});

gulp.task('minify', ['build', 'lint', 'test'], function() {
  gulp.src(['src/amdclean.js'])
    .pipe(gulp.dest('build/'))
    .pipe(uglify())
    .pipe(insert.prepend(headerText + licenseText))
    .pipe(rename('amdclean.min.js'))
    .pipe(gulp.dest('build/'));
});

// The default task (called when you run `gulp`)
gulp.task('default', ['build', 'lint', 'test', 'minify']);

// The watch task that runs the default task on any AMDclean module file changes
gulp.task('watch', function() {
  var watcher = gulp.watch('src/modules/*.js', ['default']);

  watcher.on('change', function(event) {
    console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
  });
});
<|endoftext|>


<commit_before>'use strict'

// imports

const path = require('path')

const gulp = require('gulp')
const $ = require('gulp-load-plugins')()

const browserSync = require('browser-sync').create()
const webpack = require('webpack')
const webpackStream = require('webpack-stream')
const del = require('del')

// local variables

let production = false

// tasks

gulp.task('dev', () => {
  return gulp.parallel(
    gulp.series(
      'clear',
      gulp.parallel(
        'styles',
        'templates',
        'images',
        'scripts'
      ),
      'server'
    ),
    'test',
    'test:watch',
    'styles:watch',
    'scripts:watch',
    'images:watch',
    'templates:watch'
  )()
})

gulp.task('default', gulp.series('dev'))

gulp.task('dist', () => {
  production = true

  return gulp.parallel(
    gulp.series(
      'clear',
      gulp.parallel(
        'images',
        gulp.series(
          gulp.parallel(
            'styles',
            'scripts'
          ),
          'templates'
        )
      ),
      'server'
    ),
    'test'
  )()
})

gulp.task('clear', () => del('./dist'))
gulp.task('server', () => server('./dist'))

gulp.task('scripts', () => scripts('./app/scripts/app.js', './dist/scripts/', false))
gulp.task('scripts:watch', () => scripts('./app/scripts/app.js', './dist/scripts/', true))

gulp.task('styles', () => styles('./app/styles/styles.less', './dist/styles'))
gulp.task('styles:watch', () => gulp.watch('./app/styles/**', gulp.series('styles')))

gulp.task('templates', () => templates('./app/index.html', './dist'))
gulp.task('templates:watch', () => gulp.watch('./app/**/*.html', gulp.series('templates')))

gulp.task('images', () => images('./app/images/**/*', './dist/images'))
gulp.task('images:watch', () => gulp.watch('./app/images/**/*', gulp.series('images')))

gulp.task('test', () => { test('./test/**/*.js') }) // no return, temporary fix, until https://github.com/sindresorhus/gulp-ava/issues/8 is resolved
gulp.task('test:watch', () => gulp.watch(['./test/**/*.js', './app/scripts/**/*.js'], gulp.series('test')))

// task functions

const server = (baseDir) => {
  browserSync.init({
    server: {
      baseDir: baseDir
    },
    ghostMode: false,
    port: 8080,
    open: false
  })
}

const scripts = (from, to, watch) => {
  const filter = $.filter('*.js', {restore: true})

  return gulp.src(from)
    .pipe($.plumber())
    .pipe(webpackStream({
      watch: watch,
      devtool: 'source-map',
      output: { filename: path.parse(from).base },
      module: {
        loaders: [{
          test: /\.js$/,
          exclude: /(node_modules|dist|test)/,
          loader: 'babel',
          query: {
            presets: ['es2015', 'stage-2'],
            cacheDirectory: true
          }
        }]
      },
      plugins: production ? [
        new webpack.optimize.UglifyJsPlugin({
          sourceMap: true,
          mangle: true,
          minimize: true
        }),
        new webpack.DefinePlugin({
          'process.env.NODE_ENV': production ? '"production"' : '"development"'
        })
      ] : []
    }, webpack))
    .pipe($.if(production, filter))
    .pipe($.if(production, $.rev()))
    .pipe($.if(production, filter.restore))
    .pipe(gulp.dest(to))
    .pipe($.if(production, $.rev.manifest('./dist/rev-manifest.json', {base: './dist', merge: true})))
    .pipe($.if(production, gulp.dest('./dist')))
    .pipe(browserSync.stream())
}

const styles = (from, to) => {
  return gulp.src(from)
    .pipe($.sourcemaps.init())
    .pipe($.less())
    .pipe($.autoprefixer({browsers: ['last 2 versions', 'Firefox ESR', 'ie >= 9']}))
    .pipe($.if(production, $.cleanCss()))
    .pipe($.if(production, $.rev()))
    .pipe($.sourcemaps.write('.'))
    .pipe(gulp.dest(to))
    .pipe($.if(production, $.rev.manifest('./dist/rev-manifest.json', {base: './dist', merge: true})))
    .pipe($.if(production, gulp.dest('./dist')))
    .pipe(browserSync.stream({match: '**/*.css'}))
}

const templates = (from, to) => {
  const manifest = production ? require('./dist/rev-manifest.json') : ''

  return gulp.src(from)
    .pipe($.changed(to))
    .pipe($.if(production, $.revManifestReplace({
      base: '.',
      manifest: manifest
    })))
    .pipe($.if(production, $.htmlmin({
      removeComments: true,
      collapseWhitespace: true
    })))
    .pipe(gulp.dest(to))
    .pipe(browserSync.stream())
}

const images = (from, to) => {
  return gulp.src(from)
    .pipe(gulp.dest(to))
}

const test = (files) => {
  return gulp.src(files)
    .pipe($.ava())
}
<commit_msg>make gulp-ava return properly<commit_after>'use strict'

// imports

const path = require('path')

const gulp = require('gulp')
const $ = require('gulp-load-plugins')()

const browserSync = require('browser-sync').create()
const webpack = require('webpack')
const webpackStream = require('webpack-stream')
const del = require('del')

// local variables

let production = false

// tasks

gulp.task('dev', () => {
  return gulp.parallel(
    gulp.series(
      'clear',
      gulp.parallel(
        'styles',
        'templates',
        'images',
        'scripts'
      ),
      'server'
    ),
    'test',
    'test:watch',
    'styles:watch',
    'scripts:watch',
    'images:watch',
    'templates:watch'
  )()
})

gulp.task('default', gulp.series('dev'))

gulp.task('dist', () => {
  production = true

  return gulp.parallel(
    gulp.series(
      'clear',
      gulp.parallel(
        'images',
        gulp.series(
          gulp.parallel(
            'styles',
            'scripts'
          ),
          'templates'
        )
      ),
      'server'
    ),
    'test'
  )()
})

gulp.task('clear', () => del('./dist'))
gulp.task('server', () => server('./dist'))

gulp.task('scripts', () => scripts('./app/scripts/app.js', './dist/scripts/', false))
gulp.task('scripts:watch', () => scripts('./app/scripts/app.js', './dist/scripts/', true))

gulp.task('styles', () => styles('./app/styles/styles.less', './dist/styles'))
gulp.task('styles:watch', () => gulp.watch('./app/styles/**', gulp.series('styles')))

gulp.task('templates', () => templates('./app/index.html', './dist'))
gulp.task('templates:watch', () => gulp.watch('./app/**/*.html', gulp.series('templates')))

gulp.task('images', () => images('./app/images/**/*', './dist/images'))
gulp.task('images:watch', () => gulp.watch('./app/images/**/*', gulp.series('images')))

gulp.task('test', () => test('./test/**/*.js'))
gulp.task('test:watch', () => gulp.watch(['./test/**/*.js', './app/scripts/**/*.js'], gulp.series('test')))

// task functions

const server = (baseDir) => {
  browserSync.init({
    server: {
      baseDir: baseDir
    },
    ghostMode: false,
    port: 8080,
    open: false
  })
}

const scripts = (from, to, watch) => {
  const filter = $.filter('*.js', {restore: true})

  return gulp.src(from)
    .pipe($.plumber())
    .pipe(webpackStream({
      watch: watch,
      devtool: 'source-map',
      output: { filename: path.parse(from).base },
      module: {
        loaders: [{
          test: /\.js$/,
          exclude: /(node_modules|dist|test)/,
          loader: 'babel',
          query: {
            presets: ['es2015', 'stage-2'],
            cacheDirectory: true
          }
        }]
      },
      plugins: production ? [
        new webpack.optimize.UglifyJsPlugin({
          sourceMap: true,
          mangle: true,
          minimize: true
        }),
        new webpack.DefinePlugin({
          'process.env.NODE_ENV': production ? '"production"' : '"development"'
        })
      ] : []
    }, webpack))
    .pipe($.if(production, filter))
    .pipe($.if(production, $.rev()))
    .pipe($.if(production, filter.restore))
    .pipe(gulp.dest(to))
    .pipe($.if(production, $.rev.manifest('./dist/rev-manifest.json', {base: './dist', merge: true})))
    .pipe($.if(production, gulp.dest('./dist')))
    .pipe(browserSync.stream())
}

const styles = (from, to) => {
  return gulp.src(from)
    .pipe($.sourcemaps.init())
    .pipe($.less())
    .pipe($.autoprefixer({browsers: ['last 2 versions', 'Firefox ESR', 'ie >= 9']}))
    .pipe($.if(production, $.cleanCss()))
    .pipe($.if(production, $.rev()))
    .pipe($.sourcemaps.write('.'))
    .pipe(gulp.dest(to))
    .pipe($.if(production, $.rev.manifest('./dist/rev-manifest.json', {base: './dist', merge: true})))
    .pipe($.if(production, gulp.dest('./dist')))
    .pipe(browserSync.stream({match: '**/*.css'}))
}

const templates = (from, to) => {
  const manifest = production ? require('./dist/rev-manifest.json') : ''

  return gulp.src(from)
    .pipe($.changed(to))
    .pipe($.if(production, $.revManifestReplace({
      base: '.',
      manifest: manifest
    })))
    .pipe($.if(production, $.htmlmin({
      removeComments: true,
      collapseWhitespace: true
    })))
    .pipe(gulp.dest(to))
    .pipe(browserSync.stream())
}

const images = (from, to) => {
  return gulp.src(from)
    .pipe(gulp.dest(to))
}

const test = (files) => {
  return gulp.src(files)
    .pipe($.plumber())
    .pipe($.ava())
}
<|endoftext|>


<commit_before>"use strict";

var gulp = require('gulp'),
  clean = require('gulp-clean'),
  concat = require('gulp-concat'),
  inject = require('gulp-inject'),
  rename = require('gulp-rename'),
  uglify = require('gulp-uglify'),
  es = require('event-stream');

var paths = {
  dist: 'dist',
  examples: 'example',
  libs: 'app/lib',
  debug: 'debug'
};

/**
 *
 *
 * Clean Task
 *
 *
 */
gulp.task('clean', function () {
  return gulp.src([paths.dist, paths.examples, paths.debug], {read: false})
    .pipe(clean());
});

/**
 *
 *
 * Default Task
 *
 *
 */
gulp.task('default', ['clean'], function () {
  gulp.start(paths.dist, paths.examples);
});

/**
 *
 *
 * Distribution Tasks
 *
 *
 */
gulp.task('lean-dist', ['clean'], function () {
  return leanDistributionStream()
    .pipe(gulp.dest(paths.dist));
});

gulp.task('fat-dist', ['clean'], function () {
  return fatDistributionStream()
    .pipe(gulp.dest(paths.dist));
});

gulp.task('dist', ['clean'], function () {
  gulp.start('lean-dist', 'fat-dist');
});

/**
 *
 *
 * Task for a runnable example (including index.html and app.js for bootstrapping)
 *
 *
 */
gulp.task('example', ['clean'], function () {
  gulp.start('prepare-example', 'copy-images-to-example');
});

/**
 *
 *
 * Helper tasks
 *
 *
 */

gulp.task('prepare-example', function () {
  var fatDist = fatDistributionStream()
    .pipe(gulp.dest(paths.examples + '/scripts'))
    .pipe(rename('../../scripts/threejs-billiard.fat.min.js'));

  var appJs = helperJsResourcesStream()
    .pipe(gulp.dest(paths.examples + '/scripts'))
    .pipe(rename('../../scripts/app.js'));

  var cssStream = gulp.src(['app/styles/**/*.css'])
    .pipe(concat('main.css'))
    .pipe(gulp.dest(paths.examples + '/styles'))
    .pipe(rename('../../styles/main.css'));

  return gulp.src('app/index.tpl.html')
    .pipe(inject(es.merge(fatDist, appJs, cssStream), {
      addRootSlash: false,
      sort: ensureAppJsLastLoadedComparator // ensure that app.js is the last file to include
    }))
    .pipe(rename('index.html'))
    .pipe(gulp.dest(paths.examples));
});

gulp.task('copy-images-to-example', function () {
  return gulp.src('app/images/**/*.jpg')
    .pipe(gulp.dest(paths.examples + '/images'));
});

/**
 *
 *
 * Helper functions that return streams
 *
 *
 */

function preMinifiedDependenciesStream() {
  return gulp.src([paths.lib + '/**/*.min.js'])
    .pipe(concat('pre-minified-deps.min.js'));
}

function dependenciesToMinifyStream() {
  return gulp.src([paths.lib + '/**/*.js', '!'paths.lib + '/**/*.min.js'])
    .pipe(concat('deps-to-minify.min.js'));
}

function minifiedDependenciesStream() {
  return es.merge(
    preMinifiedDependenciesStream(),
    dependenciesToMinifyStream().pipe(uglify())
  ).pipe(concat('all-deps.min.js'));
}

function minifiedJsResourcesStream() {
  // To a certain extend we need to ensure a specific loading order.
  // We can do it better in the future by using e.g. Browserify.
  return gulp.src(paths.src)
    .pipe(concat('threejs-billiard.min.js'))
    .pipe(uglify());
}

function helperJsResourcesStream() {
  return gulp.src(['app/scripts/app.js'])
    .pipe(concat('app.js'));
}

function leanDistributionStream() {
  return minifiedJsResourcesStream();
}

function fatDistributionStream() {
  return es.merge(
    minifiedDependenciesStream(),
    minifiedJsResourcesStream()
  ).pipe(concat('threejs-billiard.fat.min.js'));
}

/**
 *
 *
 * Other helper functions
 *
 *
 */

function ensureAppJsLastLoadedComparator(a, b) {
  if (/app.js/.test(a.filepath)) {
    return 1;
  }
  else if (/app.js/.test(b.filepath)) {
    return -1;
  }
  else if (/app.js/.test(a.filepath) && /app.js/.test(b.filepath)) {
    return 0;
  }
  else {
    if (a.filepath < b.filepath)
      return -1;

    if (a.filepath > b.filepath)
      return 1;

    return 0;
  }
}

/**
 *
 *
 * Debug Tasks
 *
 *
 */

gulp.task('pre-min-deps', ['clean'], function () {
  return preMinifiedDependenciesStream()
    .pipe(gulp.dest(paths.debug + '/pre-min-deps'));
});

gulp.task('min-deps', ['clean'], function () {
  return minifiedDependenciesStream()
    .pipe(gulp.dest(paths.debug + '/min-deps'));
});

gulp.task('min-code', ['clean'], function () {
  return minifiedJsResourcesStream()
    .pipe(gulp.dest(paths.debug + '/min-code'));
});

gulp.task('deps-to-min', ['clean'], function () {
  return dependenciesToMinifyStream()
    .pipe(gulp.dest(paths.debug + '/deps-to-min'));
});
<commit_msg>chore(gulp): use package.json to define component name<commit_after>"use strict";

var gulp = require('gulp'),
  clean = require('gulp-clean'),
  concat = require('gulp-concat'),
  inject = require('gulp-inject'),
  rename = require('gulp-rename'),
  uglify = require('gulp-uglify'),
  es = require('event-stream'),
  component = require('package.json');

var paths = {
  dist: 'dist',
  examples: 'example',
  libs: 'app/lib',
  debug: 'debug',
  src: [
    'app/scripts/basics/foundation.js',
    'app/scripts/basics/**/*.js',
    'app/scripts/game/helpers/coords_rotation_helper.js',
    'app/scripts/**/*.js',
    '!app/scripts/app.js'
  ]
};

/**
 *
 *
 * Clean Task
 *
 *
 */
gulp.task('clean', function () {
  return gulp.src([paths.dist, paths.examples, paths.debug], {read: false})
    .pipe(clean());
});

/**
 *
 *
 * Default Task
 *
 *
 */
gulp.task('default', ['clean'], function () {
  gulp.start(paths.dist, paths.examples);
});

/**
 *
 *
 * Distribution Tasks
 *
 *
 */
gulp.task('lean-dist', ['clean'], function () {
  return leanDistributionStream()
    .pipe(gulp.dest(paths.dist));
});

gulp.task('fat-dist', ['clean'], function () {
  return fatDistributionStream()
    .pipe(gulp.dest(paths.dist));
});

gulp.task('dist', ['clean'], function () {
  gulp.start('lean-dist', 'fat-dist');
});

/**
 *
 *
 * Task for a runnable example (including index.html and app.js for bootstrapping)
 *
 *
 */
gulp.task('example', ['clean'], function () {
  gulp.start('prepare-example', 'copy-images-to-example');
});

/**
 *
 *
 * Helper tasks
 *
 *
 */

gulp.task('prepare-example', function () {
  var fatDist = fatDistributionStream()
    .pipe(gulp.dest(paths.examples + '/scripts'))
    .pipe(rename('../../scripts/'+component.name+'.fat.min.js'));

  var appJs = helperJsResourcesStream()
    .pipe(gulp.dest(paths.examples + '/scripts'))
    .pipe(rename('../../scripts/app.js'));

  var cssStream = gulp.src(['app/styles/**/*.css'])
    .pipe(concat('main.css'))
    .pipe(gulp.dest(paths.examples + '/styles'))
    .pipe(rename('../../styles/main.css'));

  return gulp.src('app/index.tpl.html')
    .pipe(inject(es.merge(fatDist, appJs, cssStream), {
      addRootSlash: false,
      sort: ensureAppJsLastLoadedComparator // ensure that app.js is the last file to include
    }))
    .pipe(rename('index.html'))
    .pipe(gulp.dest(paths.examples));
});

gulp.task('copy-images-to-example', function () {
  return gulp.src('app/images/**/*.jpg')
    .pipe(gulp.dest(paths.examples + '/images'));
});

/**
 *
 *
 * Helper functions that return streams
 *
 *
 */

function preMinifiedDependenciesStream() {
  return gulp.src([paths.lib + '/**/*.min.js'])
    .pipe(concat('pre-minified-deps.min.js'));
}

function dependenciesToMinifyStream() {
  return gulp.src([paths.lib + '/**/*.js', '!'paths.lib + '/**/*.min.js'])
    .pipe(concat('deps-to-minify.min.js'));
}

function minifiedDependenciesStream() {
  return es.merge(
    preMinifiedDependenciesStream(),
    dependenciesToMinifyStream().pipe(uglify())
  ).pipe(concat('all-deps.min.js'));
}

function minifiedJsResourcesStream() {
  // To a certain extend we need to ensure a specific loading order.
  // We can do it better in the future by using e.g. Browserify.
  return gulp.src(paths.src)
    .pipe(concat(component.name+'.min.js'))
    .pipe(uglify());
}

function helperJsResourcesStream() {
  return gulp.src(['app/scripts/app.js'])
    .pipe(concat('app.js'));
}

function leanDistributionStream() {
  return minifiedJsResourcesStream();
}

function fatDistributionStream() {
  return es.merge(
    minifiedDependenciesStream(),
    minifiedJsResourcesStream()
  ).pipe(concat(component.name+'.fat.min.js'));
}

/**
 *
 *
 * Other helper functions
 *
 *
 */

function ensureAppJsLastLoadedComparator(a, b) {
  if (/app.js/.test(a.filepath)) {
    return 1;
  }
  else if (/app.js/.test(b.filepath)) {
    return -1;
  }
  else if (/app.js/.test(a.filepath) && /app.js/.test(b.filepath)) {
    return 0;
  }
  else {
    if (a.filepath < b.filepath)
      return -1;

    if (a.filepath > b.filepath)
      return 1;

    return 0;
  }
}

/**
 *
 *
 * Debug Tasks
 *
 *
 */

gulp.task('pre-min-deps', ['clean'], function () {
  return preMinifiedDependenciesStream()
    .pipe(gulp.dest(paths.debug + '/pre-min-deps'));
});

gulp.task('min-deps', ['clean'], function () {
  return minifiedDependenciesStream()
    .pipe(gulp.dest(paths.debug + '/min-deps'));
});

gulp.task('min-code', ['clean'], function () {
  return minifiedJsResourcesStream()
    .pipe(gulp.dest(paths.debug + '/min-code'));
});

gulp.task('deps-to-min', ['clean'], function () {
  return dependenciesToMinifyStream()
    .pipe(gulp.dest(paths.debug + '/deps-to-min'));
});
<|endoftext|>


<commit_before>var gulp          = require('gulp'),
    sass          = require('gulp-sass'),
    nano          = require('gulp-cssnano'),
    deploy        = require('gulp-gh-pages'),
    concat        = require('gulp-concat'),
    uglify        = require('gulp-uglify'),
    imagemin      = require('gulp-imagemin'),
    pngquant      = require('imagemin-pngquant'),
    minifyHTML    = require('gulp-minify-html'),
    minifyInline  = require('gulp-minify-inline'),
    size          = require('gulp-size');

// Compile Sass with autoprefixer, I've removed sourcemaps
gulp.task('scss', function() {
  gulp.src('css/basekit.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(nano({autoprefixer: {browsers: ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1']}}))
    .pipe(gulp.dest('css'))
    .pipe(size({ gzip: true, showFiles: true }));
});

// Easy deploy to the gh-pages branch
gulp.task('deploy', function () {
  return gulp.src('**/*')
    .pipe(deploy());
});

// Minify and concat the js files for use
gulp.task('js', function() {
  gulp.src('js/*.js')
    .pipe(concat('basekit.js'))
    .pipe(uglify())
    .pipe(gulp.dest('js/min'))
    .pipe(size({ gzip: true, showFiles: true }));
});

// Optimise images
gulp.task('img', function () {
  return gulp.src('imgs/*')
    .pipe(imagemin({
      progressive: true,
      svgoPlugins: [{removeViewBox: false}],
      multipass: true,
      use: [pngquant()]
    }))
    .pipe(gulp.dest('imgs'));
});

// Minify HTML source and rename the index-dev file
gulp.task('html', function() {
  gulp.src('./html/*.html')
    .pipe(minifyHTML({cdata: true}))
    .pipe(minifyInline())
    .pipe(gulp.dest('./'));
});

// Only watch Sass and JS files
gulp.task('watch', function() {
  gulp.watch('css/**/*.scss', ['scss']);
  gulp.watch('js/*.js', ['js']);
  gulp.watch('./html/*.html', ['html']);
});

gulp.task('default', ['watch']);<commit_msg>removed gulp imagemin for the time being.<commit_after>var gulp          = require('gulp'),
    sass          = require('gulp-sass'),
    nano          = require('gulp-cssnano'),

    concat        = require('gulp-concat'),
    uglify        = require('gulp-uglify'),

    // imagemin      = require('gulp-imagemin'),
    // pngquant      = require('imagemin-pngquant'),

    minifyHTML    = require('gulp-minify-html'),
    minifyInline  = require('gulp-minify-inline'),

    deploy        = require('gulp-gh-pages'),
    size          = require('gulp-size');

// Compile Sass with autoprefixer, I've removed sourcemaps
gulp.task('scss', function() {
  gulp.src('css/basekit.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(nano({autoprefixer: {browsers: ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1']}}))
    .pipe(gulp.dest('css'))
    .pipe(size({ gzip: true, showFiles: true }));
});

// Easy deploy to the gh-pages branch
gulp.task('deploy', function () {
  return gulp.src('**/*')
    .pipe(deploy());
});

// Minify and concat the js files for use
gulp.task('js', function() {
  gulp.src('js/*.js')
    .pipe(concat('basekit.js'))
    .pipe(uglify())
    .pipe(gulp.dest('js/min'))
    .pipe(size({ gzip: true, showFiles: true }));
});

// Optimise images
// gulp.task('img', function () {
//   return gulp.src('imgs/*')
//     .pipe(imagemin({
//       progressive: true,
//       svgoPlugins: [{removeViewBox: false}],
//       multipass: true,
//       use: [pngquant()]
//     }))
//     .pipe(gulp.dest('imgs'));
// });

// Minify HTML source and rename the index-dev file
gulp.task('html', function() {
  gulp.src('./html/*.html')
    .pipe(minifyHTML({cdata: true}))
    .pipe(minifyInline())
    .pipe(gulp.dest('./'));
});

// Only watch Sass and JS files
gulp.task('watch', function() {
  gulp.watch('css/**/*.scss', ['scss']);
  gulp.watch('js/*.js', ['js']);
  gulp.watch('./html/*.html', ['html']);
});

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