<commit_before>/* global require */

(function() {
    'use strict';

    var gulp = require('gulp'),
        del = require('del'),
        jshint = require('gulp-jshint'),
        jsdoc3 = require('gulp-jsdoc3'),
        jasmine = require('gulp-jasmine'),
        jscs = require('gulp-jscs'),
        webpackStream = require('webpack-stream'),
        cover = require('gulp-coverage'),
        connect = require('gulp-connect'),
        nightwatch = require('gulp-nightwatch'),
        ghPages = require('gh-pages'),
        cleanTaskName = 'clean',
        lintTaskName = 'lint',
        codestyleTaskName = 'codestyle',
        testTaskName = 'test',
        jsdocTaskName = 'jsdoc',
        webpackTaskName = 'webpack',
        copyTaskName = 'copy',
        coverageTaskName = 'coverage',
        startServerTaskName = 'startServer',
        nightwatchTaskName = 'nightwatch',
        deployTaskName = 'deploy',
        continuousTaskNameSuffix = '-continuous',
        sources = 'src/*.js',
        htmlSource = 'index.html',
        endpointSources = 'src/cribbageAnalyst.js',
        specs = 'spec/*Spec.js',
        nightwatchSpecs = 'nightwatchSpec/*.js',
        gulpfile = 'gulpfile.js',
        jshintrc = '.jshintrc',
        jscsrc = '.jscsrc',
        distFolder = 'dist/',
        staticSourceFiles = ['index.html', 'index.css'];

    gulp.task(cleanTaskName, function() {
        return del([
            // JSDoc
            'docs/',
            // webpack bundles
            distFolder,
            // nightwatch output
            'e2e_tests_output', 'e2e_test_screenshots',
            // coverageTaskName files
            '.coverdata/', '.coverrun', 'coverage',
            // site publication files
            '.publish/'
        ]);
    });

    gulp.task(lintTaskName, [cleanTaskName], function() {
        return gulp.src([sources, specs])
            .pipe(jshint())
            .pipe(jshint.reporter('default'))
            .pipe(jshint.reporter('fail'));
    });

    gulp.task(testTaskName, [lintTaskName], function() {
        return gulp.src(specs)
            .pipe(jasmine({
                includeStackTrace: true
            }));
    });

    gulp.task(jsdocTaskName, [testTaskName], function() {
        return gulp.src(sources)
            .pipe(jsdoc3());
    });

    gulp.task(codestyleTaskName, [jsdocTaskName], function() {
        return gulp.src([sources, specs, nightwatchSpecs, gulpfile])
            .pipe(jscs())
            .pipe(jscs.reporter())
            .pipe(jscs.reporter('fail'));
    });

    gulp.task(webpackTaskName, [codestyleTaskName], function() {
        return gulp.src(sources)
            .pipe(webpackStream({
                entry: {
                    cribbageAnalyst: './src/cribbageAnalyst.js'
                },
                output: {
                    filename: '[name].bundle.js',
                    libraryTarget: 'var',
                    library: '[name]'
                }
            }))
            .pipe(gulp.dest(distFolder));
    });

    // the much cheaper of the two -continuous tasks
    gulp.task(webpackTaskName + continuousTaskNameSuffix, [webpackTaskName],
        function() {
            gulp.watch([sources, specs, nightwatchSpecs, jshintrc,
                jscsrc
            ], [
                webpackTaskName
            ]);
        });

    gulp.task(copyTaskName, [webpackTaskName], function() {
        return gulp.src(staticSourceFiles).pipe(gulp.dest(distFolder));
    });

    /* must be started in separate Gulp run in order for nightwatchTaskName to
     * pass. */
    gulp.task(startServerTaskName, function() {
        connect.server({
            root: distFolder
        });
    });

    gulp.task(nightwatchTaskName, [copyTaskName], function() {
        return gulp.src('')
            .pipe(nightwatch({
                configFile: 'nightwatch.json'
            }));
    });

    gulp.task(nightwatchTaskName + continuousTaskNameSuffix, [
            nightwatchTaskName
        ],
        function() {
            gulp.watch([htmlSource, sources, specs, nightwatchSpecs,
                jshintrc, jscsrc
            ], [
                nightwatchTaskName
            ]);
        });

    /* sometimes rather expensive (> 1 minute), but thorough and expected
     * before commit. */
    gulp.task(coverageTaskName, [nightwatchTaskName], function() {
        return gulp.src(specs)
            .pipe(cover.instrument({
                pattern: [sources, '!' + endpointSources]
            }))
            .pipe(jasmine())
            .pipe(cover.gather())
            .pipe(cover.format())
            .pipe(gulp.dest('coverage'))
            .pipe(cover.enforce());
    });

    gulp.task(coverageTaskName + continuousTaskNameSuffix, [
            coverageTaskName
        ],
        function() {
            gulp.watch([htmlSource, sources, specs, nightwatchSpecs,
                jshintrc, jscsrc
            ], [
                coverageTaskName
            ]);
        });

    gulp.task(deployTaskName, [coverageTaskName], function() {
        return ghPages.publish(distFolder);
    });

    gulp.task('default', [coverageTaskName]);
}());
<commit_msg>Add deploy only Gulp task<commit_after>/* global require */

(function() {
    'use strict';

    var gulp = require('gulp'),
        del = require('del'),
        jshint = require('gulp-jshint'),
        jsdoc3 = require('gulp-jsdoc3'),
        jasmine = require('gulp-jasmine'),
        jscs = require('gulp-jscs'),
        webpackStream = require('webpack-stream'),
        cover = require('gulp-coverage'),
        connect = require('gulp-connect'),
        nightwatch = require('gulp-nightwatch'),
        ghPages = require('gh-pages'),
        cleanTaskName = 'clean',
        lintTaskName = 'lint',
        codestyleTaskName = 'codestyle',
        testTaskName = 'test',
        jsdocTaskName = 'jsdoc',
        webpackTaskName = 'webpack',
        copyTaskName = 'copy',
        coverageTaskName = 'coverage',
        startServerTaskName = 'startServer',
        nightwatchTaskName = 'nightwatch',
        onlyDeployTaskName = 'onlyDeploy',
        deployTaskName = 'deploy',
        defaultTaskName = 'default',
        continuousTaskNameSuffix = '-continuous',
        sources = 'src/*.js',
        htmlSource = 'index.html',
        endpointSources = 'src/cribbageAnalyst.js',
        specs = 'spec/*Spec.js',
        nightwatchSpecs = 'nightwatchSpec/*.js',
        gulpfile = 'gulpfile.js',
        jshintrc = '.jshintrc',
        jscsrc = '.jscsrc',
        distFolder = 'dist/',
        staticSourceFiles = ['index.html', 'index.css'];

    gulp.task(cleanTaskName, function() {
        return del([
            // JSDoc
            'docs/',
            // webpack bundles
            distFolder,
            // nightwatch output
            'e2e_tests_output', 'e2e_test_screenshots',
            // coverageTaskName files
            '.coverdata/', '.coverrun', 'coverage',
            // site publication files
            '.publish/'
        ]);
    });

    gulp.task(lintTaskName, [cleanTaskName], function() {
        return gulp.src([sources, specs])
            .pipe(jshint())
            .pipe(jshint.reporter('default'))
            .pipe(jshint.reporter('fail'));
    });

    gulp.task(testTaskName, [lintTaskName], function() {
        return gulp.src(specs)
            .pipe(jasmine({
                includeStackTrace: true
            }));
    });

    gulp.task(jsdocTaskName, [testTaskName], function() {
        return gulp.src(sources)
            .pipe(jsdoc3());
    });

    gulp.task(codestyleTaskName, [jsdocTaskName], function() {
        return gulp.src([sources, specs, nightwatchSpecs, gulpfile])
            .pipe(jscs())
            .pipe(jscs.reporter())
            .pipe(jscs.reporter('fail'));
    });

    gulp.task(webpackTaskName, [codestyleTaskName], function() {
        return gulp.src(sources)
            .pipe(webpackStream({
                entry: {
                    cribbageAnalyst: './src/cribbageAnalyst.js'
                },
                output: {
                    filename: '[name].bundle.js',
                    libraryTarget: 'var',
                    library: '[name]'
                }
            }))
            .pipe(gulp.dest(distFolder));
    });

    // the much cheaper of the two -continuous tasks
    gulp.task(webpackTaskName + continuousTaskNameSuffix, [webpackTaskName],
        function() {
            gulp.watch([sources, specs, nightwatchSpecs, jshintrc,
                jscsrc
            ], [
                webpackTaskName
            ]);
        });

    gulp.task(copyTaskName, [webpackTaskName], function() {
        return gulp.src(staticSourceFiles).pipe(gulp.dest(distFolder));
    });

    /* must be started in separate Gulp run in order for nightwatchTaskName to
     * pass. */
    gulp.task(startServerTaskName, function() {
        connect.server({
            root: distFolder
        });
    });

    gulp.task(nightwatchTaskName, [copyTaskName], function() {
        return gulp.src('')
            .pipe(nightwatch({
                configFile: 'nightwatch.json'
            }));
    });

    gulp.task(nightwatchTaskName + continuousTaskNameSuffix, [
            nightwatchTaskName
        ],
        function() {
            gulp.watch([htmlSource, sources, specs, nightwatchSpecs,
                jshintrc, jscsrc
            ], [
                nightwatchTaskName
            ]);
        });

    /* sometimes rather expensive (> 1 minute), but thorough and expected
     * before commit. */
    gulp.task(coverageTaskName, [nightwatchTaskName], function() {
        return gulp.src(specs)
            .pipe(cover.instrument({
                pattern: [sources, '!' + endpointSources]
            }))
            .pipe(jasmine())
            .pipe(cover.gather())
            .pipe(cover.format())
            .pipe(gulp.dest('coverage'))
            .pipe(cover.enforce());
    });

    gulp.task(coverageTaskName + continuousTaskNameSuffix, [
            coverageTaskName
        ],
        function() {
            gulp.watch([htmlSource, sources, specs, nightwatchSpecs,
                jshintrc, jscsrc
            ], [
                coverageTaskName
            ]);
        });

    gulp.task(onlyDeployTaskName, [], function() {
        return ghPages.publish(distFolder);
    });

    gulp.task(deployTaskName, [coverageTaskName, onlyDeployTaskName]);

    gulp.task(defaultTaskName, [coverageTaskName]);
}());
<|endoftext|>


<commit_before>var gulp    = require('gulp');
var plugins = require('gulp-load-plugins')();
var es      = require('event-stream');
var argv    = require('yargs').argv;

var paths = {
  appJavascript:    ['app/js/app.js', 'app/js/**/*.js'],
  appTemplates:     'app/js/**/*.tpl.html',
  appMainSass:      'app/scss/main.scss',
  appStyles:        'app/scss/**/*.scss',
  appImages:        'app/images/**/*',
  indexHtml:        'app/index.html',
  vendorJavascript: ['vendor/js/angular.js', 'vendor/js/**/*.js'],
  vendorCss:        ['vendor/css/**/*.css'],
  specFolder:       ['spec/**/*_spec.js'],
  tmpFolder:        'tmp',
  tmpJavascript:    'tmp/js',
  tmpAppJs:         'tmp/js/app.js',
  tmpCss:           'tmp/css',
  tmpImages:        'tmp/images',
  distFolder:       'dist',
  distJavascript:   'dist/js',
  distCss:          'dist/css',
  distImages:       'dist/images'
};

gulp.task('scripts', function() {
  return gulp.src(paths.vendorJavascript.concat(paths.appJavascript, paths.appTemplates))
    .pipe(plugins.if(/html$/, buildTemplates()))
    .pipe(plugins.concat('app.js'))
    .pipe(plugins.if(argv.production, plugins.ngAnnotate()))
    .pipe(plugins.if(argv.production, plugins.uglify()))
    .pipe(plugins.if(argv.production, gulp.dest(paths.distJavascript), gulp.dest(paths.tmpJavascript)));
});

gulp.task('styles', function() {
  return gulp.src(paths.vendorCss.concat(paths.appMainSass))
    .pipe(plugins.if(/scss$/, plugins.sass()))
    .pipe(plugins.concat('app.css'))
    .pipe(plugins.if(argv.production, plugins.minifyCss()))
    .pipe(plugins.if(argv.production, gulp.dest(paths.distCss), gulp.dest(paths.tmpCss)));
});

gulp.task('images', function() {
  return gulp.src(paths.appImages)
    .pipe(plugins.if(argv.production, gulp.dest(paths.distImages), gulp.dest(paths.tmpImages)));
});

gulp.task('indexHtml', function() {
  return gulp.src(paths.indexHtml)
    .pipe(plugins.if(argv.production, gulp.dest(paths.distFolder), gulp.dest(paths.tmpFolder)));
});

gulp.task('lint', function() {
  return gulp.src(paths.appJavascript.concat(paths.specFolder))
    .pipe(plugins.jshint())
    .pipe(plugins.jshint.reporter('jshint-stylish'));
});

gulp.task('testem', function() {
  return gulp.src(['']) // We don't need files, that is managed on testem.json
    .pipe(plugins.testem({
      configFile: 'testem.json'
    }));
});

gulp.task('clean', function() {
  return gulp.src([paths.tmpFolder, paths.distFolder], {read: false})
    .pipe(plugins.rimraf());
});

gulp.task('watch', ['webserver'], function() {
  gulp.watch(paths.appJavascript, ['lint', 'scripts']);
  gulp.watch(paths.appTemplates, ['scripts']);
  gulp.watch(paths.vendorJavascript, ['scripts']);
  gulp.watch(paths.appImages, ['images']);
  gulp.watch(paths.specFolder, ['lint']);
  gulp.watch(paths.indexHtml, ['indexHtml']);
  gulp.watch(paths.appStyles, ['styles']);
});

gulp.task('webserver', ['scripts', 'styles', 'images', 'indexHtml'], function() {
  gulp.src(paths.tmpFolder)
    .pipe(plugins.webserver({
      port: 5000,
      proxies: [
        {
          source: '/api', target: 'http://localhost:8080/api'
        }
      ]
    }));
});

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

function buildTemplates() {
  return es.pipeline(
    plugins.minifyHtml({
      empty: true,
      spare: true,
      quotes: true
    }),
    plugins.angularTemplatecache({
      module: 'app'
    })
  );
}
<commit_msg>Add missing watcher for vendor css<commit_after>var gulp    = require('gulp');
var plugins = require('gulp-load-plugins')();
var es      = require('event-stream');
var argv    = require('yargs').argv;

var paths = {
  appJavascript:    ['app/js/app.js', 'app/js/**/*.js'],
  appTemplates:     'app/js/**/*.tpl.html',
  appMainSass:      'app/scss/main.scss',
  appStyles:        'app/scss/**/*.scss',
  appImages:        'app/images/**/*',
  indexHtml:        'app/index.html',
  vendorJavascript: ['vendor/js/angular.js', 'vendor/js/**/*.js'],
  vendorCss:        ['vendor/css/**/*.css'],
  specFolder:       ['spec/**/*_spec.js'],
  tmpFolder:        'tmp',
  tmpJavascript:    'tmp/js',
  tmpAppJs:         'tmp/js/app.js',
  tmpCss:           'tmp/css',
  tmpImages:        'tmp/images',
  distFolder:       'dist',
  distJavascript:   'dist/js',
  distCss:          'dist/css',
  distImages:       'dist/images'
};

gulp.task('scripts', function() {
  return gulp.src(paths.vendorJavascript.concat(paths.appJavascript, paths.appTemplates))
    .pipe(plugins.if(/html$/, buildTemplates()))
    .pipe(plugins.concat('app.js'))
    .pipe(plugins.if(argv.production, plugins.ngAnnotate()))
    .pipe(plugins.if(argv.production, plugins.uglify()))
    .pipe(plugins.if(argv.production, gulp.dest(paths.distJavascript), gulp.dest(paths.tmpJavascript)));
});

gulp.task('styles', function() {
  return gulp.src(paths.vendorCss.concat(paths.appMainSass))
    .pipe(plugins.if(/scss$/, plugins.sass()))
    .pipe(plugins.concat('app.css'))
    .pipe(plugins.if(argv.production, plugins.minifyCss()))
    .pipe(plugins.if(argv.production, gulp.dest(paths.distCss), gulp.dest(paths.tmpCss)));
});

gulp.task('images', function() {
  return gulp.src(paths.appImages)
    .pipe(plugins.if(argv.production, gulp.dest(paths.distImages), gulp.dest(paths.tmpImages)));
});

gulp.task('indexHtml', function() {
  return gulp.src(paths.indexHtml)
    .pipe(plugins.if(argv.production, gulp.dest(paths.distFolder), gulp.dest(paths.tmpFolder)));
});

gulp.task('lint', function() {
  return gulp.src(paths.appJavascript.concat(paths.specFolder))
    .pipe(plugins.jshint())
    .pipe(plugins.jshint.reporter('jshint-stylish'));
});

gulp.task('testem', function() {
  return gulp.src(['']) // We don't need files, that is managed on testem.json
    .pipe(plugins.testem({
      configFile: 'testem.json'
    }));
});

gulp.task('clean', function() {
  return gulp.src([paths.tmpFolder, paths.distFolder], {read: false})
    .pipe(plugins.rimraf());
});

gulp.task('watch', ['webserver'], function() {
  gulp.watch(paths.appJavascript, ['lint', 'scripts']);
  gulp.watch(paths.appTemplates, ['scripts']);
  gulp.watch(paths.vendorJavascript, ['scripts']);
  gulp.watch(paths.appImages, ['images']);
  gulp.watch(paths.specFolder, ['lint']);
  gulp.watch(paths.indexHtml, ['indexHtml']);
  gulp.watch(paths.appStyles, ['styles']);
  gulp.watch(paths.vendorCss, ['styles']);
});

gulp.task('webserver', ['scripts', 'styles', 'images', 'indexHtml'], function() {
  gulp.src(paths.tmpFolder)
    .pipe(plugins.webserver({
      port: 5000,
      proxies: [
        {
          source: '/api', target: 'http://localhost:8080/api'
        }
      ]
    }));
});

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

function buildTemplates() {
  return es.pipeline(
    plugins.minifyHtml({
      empty: true,
      spare: true,
      quotes: true
    }),
    plugins.angularTemplatecache({
      module: 'app'
    })
  );
}
<|endoftext|>


<commit_before>'use strict';

var argv = require('yargs').argv;
var browserify = require('browserify');
var buffer = require('vinyl-buffer');
var del = require('del');
var gulp = require('gulp');
var karma = require('karma').server;
var LessPluginCleanCSS = require('less-plugin-clean-css');
var cleancss = new LessPluginCleanCSS({ advanced: true });
var plugins = require('gulp-load-plugins')();
var source = require('vinyl-source-stream');

var bundler = browserify({
  entries: ['./public/javascripts/app/main.js'],
  debug: !argv.production,
  cache: {},
  packageCache: {},
  fullPaths: true // for watchify
});

var docker = {
  repo: 'waltzofpearls/shorten.js',
  name: 'shorten.js',
  port: '49003'
};

//
// $ gulp less
//
gulp.task('less', function() {
  return gulp.src('./public/stylesheets/style.less')
    .pipe(plugins.sourcemaps.init())
    .pipe(plugins.if( argv.production, plugins.less({plugins: [cleancss]}), plugins.less() ))
    .pipe(plugins.sourcemaps.write('./'))
    .pipe(gulp.dest('./public/stylesheets'));
});

//
// $ gulp browserify
//
gulp.task('browserify', function() {
  return bundler
    .bundle()
    .pipe(source('bundle.js'))
    .pipe(buffer())
    .pipe(plugins.if( argv.production, plugins.sourcemaps.init({ loadMaps: true }) ))
    .pipe(plugins.if( argv.production, plugins.uglify() ))
    .pipe(plugins.if( argv.production, plugins.sourcemaps.write('./') ))
    .pipe(gulp.dest('./public/javascripts/app/'));
});

//
// $ gulp watchify
//
gulp.task('watchify', function() {
  var watcher  = watchify(bundler);
  return watcher
    .on('error', plugins.util.log.bind(plugins.util, 'Browserify Error'))
    .on('update', function() {
      watcher.bundle()
        .pipe(source('bundle.js'))
        .pipe(buffer())
        .pipe(sourcemaps.init({ loadMaps: true }))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./public/javascripts/app/'));

      plugins.util.log("Updated JavaScript sources");
    })
    .bundle() // Create the initial bundle when starting the task
    .pipe(source('bundle.js'))
    .pipe(gulp.dest('./public/javascripts/app/'));
});

//
// $ gulp less-watch
//
gulp.task('less-watch', function () {
  gulp.watch('./public/stylesheets/**/*.less', ['less']);
});

//
// $ gulp clean
//
gulp.task('clean', function(done) {
  del([
    './public/javascripts/app/bundle.js',
    './public/javascripts/app/bundle.js.map',
    './public/stylesheets/style.css',
    './public/stylesheets/style.css.map'
  ], done);
});

//
// $ gulp mocha-test
//
gulp.task('mocha-test', function() {
  return gulp.src('./tests/unit-node/**/*_test.js')
    .pipe(plugins.mocha({
      reporter: 'spec',
      bail: true,
      ignoreLeaks: false
    }));
});

//
// $ gulp karma-tdd
//
gulp.task('karma-tdd', function(done) {
  karma.start({
    configFile: __dirname + '/tests/karma.conf.js'
  }, done);
});

//
// $ gulp karma-single-run
//
gulp.task('karma-single-run', function(done) {
  karma.start({
    configFile: __dirname + '/tests/karma.conf.js',
    singleRun: true
  }, done);
});

//
// $ gulp docker:build
//
gulp.task('docker:build', plugins.shell.task([
  'docker build -t <%= repo %> .'
], { templateData: docker }));

//
// $ gulp docker:run:prod
//
gulp.task('docker:run:prod', plugins.shell.task([
  'docker run -p <%= port %>:3000 -d -e NODE_ENV=production --name <%= name %> <%= repo %>'
], { templateData: docker }));

//
// $ gulp docker:run:test
//
gulp.task('docker:run:test', plugins.shell.task([
  'docker run -p <%= port %>:3000 -d -e NODE_ENV=testing --name <%= name %> <%= repo %>'
], { templateData: docker }));

//
// $ gulp docker:run:dev
//
gulp.task('docker:run:dev', plugins.shell.task([
  'docker run -p <%= port %>:3000 -d -e NODE_ENV=development --name <%= name %> <%= repo %>'
], { templateData: docker }));

//
// $ gulp docker:stop
//
gulp.task('docker:stop', plugins.shell.task([
  'docker ps -a | grep <%= name %> > /dev/null \
  && docker stop <%= name %> \
  && docker rm <%= name %> \
  || echo "\nDocker container [<%= name %>] does not exist."'
], { templateData: docker }));

//
// $ gulp docker:status
//
gulp.task('docker:status', plugins.shell.task([
  'docker ps -a -f name=<%= name %>'
], { templateData: docker }));

//
// $ gulp docker:purge
//
gulp.task('docker:purge', plugins.shell.task([
  'docker images | grep <%= repo %> > /dev/null \
  && docker rmi <%= repo %> \
  || echo "\nDocker image [<%= repo %>] does not exist."'
], { templateData: docker }));

//
// $ gulp docker:push
//
gulp.task('docker:push', plugins.shell.task([
  'docker push <%= repo %>'
], { templateData: docker }));

//
// $ gulp docker:pull
//
gulp.task('docker:pull', plugins.shell.task([
  'docker pull <%= repo %>'
], { templateData: docker }));

//
// $ gulp build
// $ gulp build:js
// $ gulp build:css
//
gulp.task('build:css', ['less']);
gulp.task('build:js', ['browserify']);
gulp.task('build', ['build:css', 'build:js']);

//
// $ gulp watch
// $ gulp watch:js
// $ gulp watch:css
//
gulp.task('watch:css', ['less-watch']);
gulp.task('watch:js', ['watchify']);
gulp.task('watch', ['watch:css', 'watch:js']);

//
// $ gulp tdd
// $ gulp tdd:backend
// $ gulp tdd:frontend
//
gulp.task('tdd:frontend', ['karma-tdd']);
gulp.task('tdd:backend', ['mocha-test']);
gulp.task('tdd', ['tdd:backend', 'tdd:frontend']);

//
// $ gulp test
// $ gulp test:backend
// $ gulp test:frontend
//
gulp.task('test:frontend', ['karma-single-run']);
gulp.task('test:backend', ['mocha-test']);
gulp.task('test', ['test:backend', 'test:frontend']);

//
// Gulp's default task
//
// $ gulp
//
gulp.task('default', ['build']);
<commit_msg>Added missing require for watchify<commit_after>'use strict';

var argv = require('yargs').argv;
var browserify = require('browserify');
var buffer = require('vinyl-buffer');
var del = require('del');
var gulp = require('gulp');
var karma = require('karma').server;
var LessPluginCleanCSS = require('less-plugin-clean-css');
var plugins = require('gulp-load-plugins')();
var source = require('vinyl-source-stream');
var watchify = require('watchify');

var cleancss = new LessPluginCleanCSS({ advanced: true });

var bundler = browserify({
  entries: ['./public/javascripts/app/main.js'],
  debug: !argv.production,
  cache: {},
  packageCache: {},
  fullPaths: true // for watchify
});

var docker = {
  repo: 'waltzofpearls/shorten.js',
  name: 'shorten.js',
  port: '49003'
};

//
// $ gulp less
//
gulp.task('less', function() {
  return gulp.src('./public/stylesheets/style.less')
    .pipe(plugins.sourcemaps.init())
    .pipe(plugins.if( argv.production, plugins.less({plugins: [cleancss]}), plugins.less() ))
    .pipe(plugins.sourcemaps.write('./'))
    .pipe(gulp.dest('./public/stylesheets'));
});

//
// $ gulp browserify
//
gulp.task('browserify', function() {
  return bundler
    .bundle()
    .pipe(source('bundle.js'))
    .pipe(buffer())
    .pipe(plugins.if( argv.production, plugins.sourcemaps.init({ loadMaps: true }) ))
    .pipe(plugins.if( argv.production, plugins.uglify() ))
    .pipe(plugins.if( argv.production, plugins.sourcemaps.write('./') ))
    .pipe(gulp.dest('./public/javascripts/app/'));
});

//
// $ gulp watchify
//
gulp.task('watchify', function() {
  var watcher  = watchify(bundler);
  return watcher
    .on('error', plugins.util.log.bind(plugins.util, 'Browserify Error'))
    .on('update', function() {
      watcher.bundle()
        .pipe(source('bundle.js'))
        .pipe(buffer())
        .pipe(sourcemaps.init({ loadMaps: true }))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./public/javascripts/app/'));

      plugins.util.log("Updated JavaScript sources");
    })
    .bundle() // Create the initial bundle when starting the task
    .pipe(source('bundle.js'))
    .pipe(gulp.dest('./public/javascripts/app/'));
});

//
// $ gulp less-watch
//
gulp.task('less-watch', function () {
  gulp.watch('./public/stylesheets/**/*.less', ['less']);
});

//
// $ gulp clean
//
gulp.task('clean', function(done) {
  del([
    './public/javascripts/app/bundle.js',
    './public/javascripts/app/bundle.js.map',
    './public/stylesheets/style.css',
    './public/stylesheets/style.css.map'
  ], done);
});

//
// $ gulp mocha-test
//
gulp.task('mocha-test', function() {
  return gulp.src('./tests/unit-node/**/*_test.js')
    .pipe(plugins.mocha({
      reporter: 'spec',
      bail: true,
      ignoreLeaks: false
    }));
});

//
// $ gulp karma-tdd
//
gulp.task('karma-tdd', function(done) {
  karma.start({
    configFile: __dirname + '/tests/karma.conf.js'
  }, done);
});

//
// $ gulp karma-single-run
//
gulp.task('karma-single-run', function(done) {
  karma.start({
    configFile: __dirname + '/tests/karma.conf.js',
    singleRun: true
  }, done);
});

//
// $ gulp docker:build
//
gulp.task('docker:build', plugins.shell.task([
  'docker build -t <%= repo %> .'
], { templateData: docker }));

//
// $ gulp docker:run:prod
//
gulp.task('docker:run:prod', plugins.shell.task([
  'docker run -p <%= port %>:3000 -d -e NODE_ENV=production --name <%= name %> <%= repo %>'
], { templateData: docker }));

//
// $ gulp docker:run:test
//
gulp.task('docker:run:test', plugins.shell.task([
  'docker run -p <%= port %>:3000 -d -e NODE_ENV=testing --name <%= name %> <%= repo %>'
], { templateData: docker }));

//
// $ gulp docker:run:dev
//
gulp.task('docker:run:dev', plugins.shell.task([
  'docker run -p <%= port %>:3000 -d -e NODE_ENV=development --name <%= name %> <%= repo %>'
], { templateData: docker }));

//
// $ gulp docker:stop
//
gulp.task('docker:stop', plugins.shell.task([
  'docker ps -a | grep <%= name %> > /dev/null \
  && docker stop <%= name %> \
  && docker rm <%= name %> \
  || echo "\nDocker container [<%= name %>] does not exist."'
], { templateData: docker }));

//
// $ gulp docker:status
//
gulp.task('docker:status', plugins.shell.task([
  'docker ps -a -f name=<%= name %>'
], { templateData: docker }));

//
// $ gulp docker:purge
//
gulp.task('docker:purge', plugins.shell.task([
  'docker images | grep <%= repo %> > /dev/null \
  && docker rmi <%= repo %> \
  || echo "\nDocker image [<%= repo %>] does not exist."'
], { templateData: docker }));

//
// $ gulp docker:push
//
gulp.task('docker:push', plugins.shell.task([
  'docker push <%= repo %>'
], { templateData: docker }));

//
// $ gulp docker:pull
//
gulp.task('docker:pull', plugins.shell.task([
  'docker pull <%= repo %>'
], { templateData: docker }));

//
// $ gulp build
// $ gulp build:js
// $ gulp build:css
//
gulp.task('build:css', ['less']);
gulp.task('build:js', ['browserify']);
gulp.task('build', ['build:css', 'build:js']);

//
// $ gulp watch
// $ gulp watch:js
// $ gulp watch:css
//
gulp.task('watch:css', ['less-watch']);
gulp.task('watch:js', ['watchify']);
gulp.task('watch', ['watch:css', 'watch:js']);

//
// $ gulp tdd
// $ gulp tdd:backend
// $ gulp tdd:frontend
//
gulp.task('tdd:frontend', ['karma-tdd']);
gulp.task('tdd:backend', ['mocha-test']);
gulp.task('tdd', ['tdd:backend', 'tdd:frontend']);

//
// $ gulp test
// $ gulp test:backend
// $ gulp test:frontend
//
gulp.task('test:frontend', ['karma-single-run']);
gulp.task('test:backend', ['mocha-test']);
gulp.task('test', ['test:backend', 'test:frontend']);

//
// Gulp's default task
//
// $ gulp
//
gulp.task('default', ['build']);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var jshint = require('gulp-jshint');
var jasmine = require('gulp-jasmine');
var sass = require('gulp-sass');
var browserify = require('browserify');
var watchify = require('watchify');
var reactify = require('reactify');
var vinylStream = require('vinyl-source-stream');
var del = require('del');
var alert = require('./gulp/gulp-alert');
var stream = require('stream');

gulp.task('clean', function () {
    return del('./dist/**/*.*');
});

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

//jasmine
gulp.task('test', [ 'lint' ], function () {
    return gulp.src('./spec/**/*-spec.js')
        .pipe(jasmine());
});

gulp.task('sass', function () {
    gulp.src('./styles/calc.scss')
        .pipe(sass())
        .pipe(gulp.dest('./styles'));
});

gulp.task('stream-test', function () {

    //create a text stream
    var str = new stream.Readable();
    str.push('hello world');
    str.push(null);

    //convert stream to vinyl
    str.pipe(vinylStream('testy.txt'))

    //send to file
    .pipe(gulp.dest('./dist'));
});

//package with browserify
gulp.task('package', [ 'test', 'clean' ], function() {
    return browserify({
        entries: './lib/index.js',
        standalone: "calc"
    })
    //bundler.ignore('react');
    .transform(reactify)
    .bundle()
    .pipe(vinylStream('calc.js'))
    .pipe(alert('Welcome to the calculator!'))
    .pipe(gulp.dest('./dist'));
});

//start watching for changes
gulp.task('watch', function() {
    var bundler = watchify(browserify({
        entries: './lib/index.js',
        standalone: "calc"
    }), watchify.args);

    //uncomment to use react as a browser dependency
    //bundler.ignore('react');
    bundler.transform(reactify);

    bundler.on('update', rebundle);

    gulp.watch('./styles/*.scss', ['sass']);

    function rebundle() {

        return bundler.bundle()
            .pipe(vinylStream('calc.js'))
            .pipe(alert('Welcome to the calculator! (built by watch)'))
            .pipe(gulp.dest('./dist'));
    }

    return rebundle();
});

gulp.task('default', ['package']);<commit_msg>Renaming custom gulp plugin<commit_after>var gulp = require('gulp');
var jshint = require('gulp-jshint');
var jasmine = require('gulp-jasmine');
var sass = require('gulp-sass');
var browserify = require('browserify');
var watchify = require('watchify');
var reactify = require('reactify');
var vinylStream = require('vinyl-source-stream');
var del = require('del');
var appendAlert = require('./gulp/gulp-alert');
var stream = require('stream');

gulp.task('clean', function () {
    return del('./dist/**/*.*');
});

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

//jasmine
gulp.task('test', [ 'lint' ], function () {
    return gulp.src('./spec/**/*-spec.js')
        .pipe(jasmine());
});

gulp.task('sass', function () {
    gulp.src('./styles/calc.scss')
        .pipe(sass())
        .pipe(gulp.dest('./styles'));
});

gulp.task('stream-test', function () {

    //create a text stream
    var str = new stream.Readable();
    str.push('hello world');
    str.push(null);

    //convert stream to vinyl
    str.pipe(vinylStream('testy.txt'))

    //send to file
    .pipe(gulp.dest('./dist'));
});

//package with browserify
gulp.task('package', [ 'sass', 'test', 'clean' ], function() {
    return browserify({
        entries: './lib/index.js',
        standalone: 'calc'
    })
    //bundler.ignore('react');
    .transform(reactify)
    .bundle()
    .pipe(vinylStream('calc.js'))
    .pipe(appendAlert('Welcome to the calculator!'))
    .pipe(gulp.dest('./dist'));
});

//start watching for changes
gulp.task('watch', function() {
    var bundler = watchify(browserify({
        entries: './lib/index.js',
        standalone: 'calc'
    }), watchify.args);

    //uncomment to use react as a browser dependency
    //bundler.ignore('react');
    bundler.transform(reactify);

    bundler.on('update', rebundle);

    gulp.watch('./styles/*.scss', ['sass']);

    function rebundle() {

        return bundler.bundle()
            .pipe(vinylStream('calc.js'))
            .pipe(appendAlert('Welcome to the calculator! (built by watch)'))
            .pipe(gulp.dest('./dist'));
    }

    return rebundle();
});

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


<commit_before>/**
 *  The '--production' parameter allows to minimize the JS and CSS code.
 *
 *  Minimal requirements: NodeJS v6.9+, gulp module installed globally, i.e., use 'npm install -g gulp'.
 *
 *  NOTE: for the first time, one need to execute: 'npm install' to get all the NodeJS
 *        dependency modules described in the package.json file and used by this gulp file.
 */

// dependency NodeJS modules
const argv = require( "yargs").argv,
  gulp = require( "gulp"),
  concat = require( "gulp-concat"),
  notify = require("gulp-notify"),
  gulpif = require("gulp-if"),
  uglify = require("gulp-uglify"),
  tap = require("gulp-tap"),
  del = require("del"),
  jshint = require('gulp-jshint');

// the folder where the distribution library file is created.
const buildFolder = "dist";

// the JS files of the cLASSjs Browser Library
const cLASSjsBrowserLibFiles = [
  "lib/browserShims.js",

  "lib/errorTypes.js",
  "lib/util.js",
  "src/eNUMERATION.js",
  "src/cLASS.js",

  "lib/dom.js",
  "src/oBJECTvIEW.js",

  "lib/idb.js",
  "src/storage/sTORAGEmANAGER.js",
  "src/storage/sTORAGEmANAGER_IndexedDB.js"
];

// the JS files of the cLASSjs Worker Library
const cLASSjsWorkerLibFiles = [
  "lib/browserShims.js",
  "lib/errorTypes.js",
  "lib/util.js",
  "src/eNUMERATION.js",
  "src/cLASS.js",
  "lib/idb.js",
  "src/storage/sTORAGEmANAGER.js",
  "src/storage/sTORAGEmANAGER_IndexedDB.js"
];

// build the cLASSjsBrowserLib.js file
gulp.task( "build-browser-lib", function() {
  return gulp.src( cLASSjsBrowserLibFiles)
    .pipe( concat("cLASSjsBrowserLib.js"))
    .pipe( gulpif( argv.production, uglify()))
    .pipe( gulp.dest( buildFolder))
    .pipe( notify({message: "cLASSjsBrowserLib.js was built!"}));
});
// build the cLASSjsWorkerLib.js file
gulp.task( "build-worker-lib", function() {
  return gulp.src( cLASSjsWorkerLibFiles)
      .pipe( concat("cLASSjsWorkerLib.js"))
      .pipe( gulpif( argv.production, uglify()))
      .pipe( gulp.dest( buildFolder))
      .pipe( notify({message: "cLASSjsWorkerLib.js was built!"}));
});
gulp.task( "build", [
    "build-browser-lib",
    "build-worker-lib"
]);

// build the cLASSjsNodeLib.js file
gulp.task( "build-node", function() {
  return gulp.src([
    "lib/errorTypes.js",
    "lib/util.js",
    "src/eNUMERATION.js",
    "src/cLASS.js"
  ])
      .pipe( concat("cLASSjsNodeLib.js"))
      .pipe( gulpif( argv.production, uglify()))
      .pipe( gulp.dest( buildFolder))
      .pipe( notify({message: "cLASSjsNodeLib.js was built!"}));
});

gulp.task('dev', function () {
  gulp.src([
      "lib/browserShims.js",
      "lib/errorTypes.js",
      "lib/util.js",
  	  "src/eNUMERATION.js",
      "src/cLASS.js",
      "lib/dom.js",
      "src/oBJECTvIEW.js"
  ])
    .pipe(jshint('.jshintrc'))
    .pipe(jshint.reporter('default'));
});
<commit_msg>minor<commit_after>/**
 *  The '--production' parameter allows to minimize the JS and CSS code.
 *
 *  Minimal requirements: NodeJS v6.9+, gulp module installed globally, i.e., use 'npm install -g gulp'.
 *
 *  NOTE: for the first time, one need to execute: 'npm install' to get all the NodeJS
 *        dependency modules described in the package.json file and used by this gulp file.
 */

// dependency NodeJS modules
const argv = require( "yargs").argv,
  gulp = require( "gulp"),
  concat = require( "gulp-concat"),
  notify = require("gulp-notify"),
  gulpif = require("gulp-if"),
  uglify = require("gulp-uglify"),
  //cleanCSS = require("gulp-clean-css"),
  tap = require("gulp-tap"),
  del = require("del"),
  jshint = require('gulp-jshint');

// the folder where the distribution library file is created.
const buildFolder = "dist";

// the JS files of the cLASSjs Browser Library
const cLASSjsBrowserLibFiles = [
  "lib/browserShims.js",

  "lib/errorTypes.js",
  "lib/util.js",
  "src/eNUMERATION.js",
  "src/cLASS.js",

  "lib/dom.js",
  "src/oBJECTvIEW.js",

  "lib/idb.js",
  "src/storage/sTORAGEmANAGER.js",
  "src/storage/sTORAGEmANAGER_IndexedDB.js"
];

// the JS files of the cLASSjs Worker Library
const cLASSjsWorkerLibFiles = [
  "lib/browserShims.js",
  "lib/errorTypes.js",
  "lib/util.js",
  "src/eNUMERATION.js",
  "src/cLASS.js",
  "lib/idb.js",
  "src/storage/sTORAGEmANAGER.js",
  "src/storage/sTORAGEmANAGER_IndexedDB.js"
];

// build the cLASSjsBrowserLib.js file
gulp.task( "build-browser-lib", function() {
  return gulp.src( cLASSjsBrowserLibFiles)
    .pipe( concat("cLASSjsBrowserLib.js"))
    .pipe( gulpif( argv.production, uglify()))
    .pipe( gulp.dest( buildFolder))
    .pipe( notify({message: "cLASSjsBrowserLib.js was built!"}));
});
gulp.task( "build-css", function() {
  return gulp.src(
    [ "css/normalize.css",
      "css/vIEW.css"
	])
    .pipe( concat( "cLASS.css"))
//    .pipe( gulpif( argv.production, cleanCSS()))
    .pipe( gulp.dest( buildFolder))
});
// build the cLASSjsWorkerLib.js file
gulp.task( "build-worker-lib", function() {
  return gulp.src( cLASSjsWorkerLibFiles)
      .pipe( concat("cLASSjsWorkerLib.js"))
      .pipe( gulpif( argv.production, uglify()))
      .pipe( gulp.dest( buildFolder))
      .pipe( notify({message: "cLASSjsWorkerLib.js was built!"}));
});
gulp.task( "build", [
    "build-browser-lib",
	"build-css",
    "build-worker-lib"
]);

// build the cLASSjsNodeLib.js file
gulp.task( "build-node", function() {
  return gulp.src([
    "lib/errorTypes.js",
    "lib/util.js",
    "src/eNUMERATION.js",
    "src/cLASS.js"
  ])
      .pipe( concat("cLASSjsNodeLib.js"))
      .pipe( gulpif( argv.production, uglify()))
      .pipe( gulp.dest( buildFolder))
      .pipe( notify({message: "cLASSjsNodeLib.js was built!"}));
});

gulp.task('dev', function () {
  gulp.src([
      "lib/browserShims.js",
      "lib/errorTypes.js",
      "lib/util.js",
  	  "src/eNUMERATION.js",
      "src/cLASS.js",
      "lib/dom.js",
      "src/oBJECTvIEW.js"
  ])
    .pipe(jshint('.jshintrc'))
    .pipe(jshint.reporter('default'));
});
<|endoftext|>


<commit_before>var gulp        = require('gulp'),
	plumber     = require('gulp-plumber'),
	browserSync = require('browser-sync'),
	stylus      = require('gulp-stylus'),
	uglify      = require('gulp-uglify'),
	concat      = require('gulp-concat'),
	jeet        = require('jeet'),
	rupture     = require('rupture'),
	koutoSwiss  = require('kouto-swiss'),
	prefixer    = require('autoprefixer-stylus'),
	imagemin    = require('gulp-imagemin'),
	cp          = require('child_process');

var messages = {
	jekyllBuild: 'Running: $ jekyll build'
};

var jekyllCommand = (/^win/.test(process.platform)) ? 'jekyll.bat' : 'jekyll';

/**
 * Build the Jekyll Site
 */
function jekyllBuild() {
	browserSync.notify(messages.jekyllBuild);
	return cp.spawn(jekyllCommand, ['build'], {stdio: 'inherit'});
}

function reloadBrowserSync(done) {
	browserSync.reload();
	done();
}

function doBrowserSync(done) {
	browserSync.init({
    server: {
      baseDir: "./_site/"
    },
    port: 3000
  });
  done();
}

function runStylus() {
	return gulp.src('src/styl/main.styl')
		.pipe(plumber())
		.pipe(stylus({
			use:[koutoSwiss(), prefixer(), jeet(), rupture()],
			compress: true
		}))
		.pipe(gulp.dest('_site/assets/css/'))
		.pipe(browserSync.reload({stream:true}))
		.pipe(gulp.dest('assets/css'));
}

function runJs() {
	return gulp.src('src/js/**/*.js')
		.pipe(plumber())
		.pipe(concat('main.js'))
		.pipe(uglify())
		.pipe(gulp.dest('assets/js/'));
}

function runImagemin() {
	return gulp.src('src/img/**/*.{jpg,png,gif,PNG,JPG}')
		.pipe(plumber())
		.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
		.pipe(gulp.dest('img/'));
}

/**
 * Watch stylus files for changes & recompile
 * Watch html/md files, run jekyll & reload BrowserSync
 */
function watch() {
	gulp.watch('src/styl/**/*.styl', runStylus);
	gulp.watch('src/js/**/*.js', runJs);
	gulp.watch('src/img/**/*.{jpg,png,gif,PNG,JPG}', runImagemin);
	gulp.watch(['*.html', 'about/index.html', 'blog/index.html', '_includes/*.html', '_layouts/*.html', '_posts/*'],
		gulp.series(jekyllBuild, reloadBrowserSync));
}

/**
 * Default task, running just `gulp` will compile the sass,
 * compile the jekyll site, launch BrowserSync & watch files.
 */
gulp.task('default', gulp.series(runJs, runStylus, gulp.series(jekyllBuild, doBrowserSync), watch));
<commit_msg>add gulp task to compile js and stylus<commit_after>var gulp        = require('gulp'),
	plumber     = require('gulp-plumber'),
	browserSync = require('browser-sync'),
	stylus      = require('gulp-stylus'),
	uglify      = require('gulp-uglify'),
	concat      = require('gulp-concat'),
	jeet        = require('jeet'),
	rupture     = require('rupture'),
	koutoSwiss  = require('kouto-swiss'),
	prefixer    = require('autoprefixer-stylus'),
	imagemin    = require('gulp-imagemin'),
	cp          = require('child_process');

var messages = {
	jekyllBuild: 'Running: $ jekyll build'
};

var jekyllCommand = (/^win/.test(process.platform)) ? 'jekyll.bat' : 'jekyll';

/**
 * Build the Jekyll Site
 */
function jekyllBuild() {
	browserSync.notify(messages.jekyllBuild);
	return cp.spawn(jekyllCommand, ['build'], {stdio: 'inherit'});
}

function reloadBrowserSync(done) {
	browserSync.reload();
	done();
}

function doBrowserSync(done) {
	browserSync.init({
    server: {
      baseDir: "./_site/"
    },
    port: 3000
  });
  done();
}

function runStylus() {
	return gulp.src('src/styl/main.styl')
		.pipe(plumber())
		.pipe(stylus({
			use:[koutoSwiss(), prefixer(), jeet(), rupture()],
			compress: true
		}))
		.pipe(gulp.dest('_site/assets/css/'))
		.pipe(browserSync.reload({stream:true}))
		.pipe(gulp.dest('assets/css'));
}

function runJs() {
	return gulp.src('src/js/**/*.js')
		.pipe(plumber())
		.pipe(concat('main.js'))
		.pipe(uglify())
		.pipe(gulp.dest('assets/js/'));
}

function runImagemin() {
	return gulp.src('src/img/**/*.{jpg,png,gif,PNG,JPG}')
		.pipe(plumber())
		.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
		.pipe(gulp.dest('img/'));
}

/**
 * Watch stylus files for changes & recompile
 * Watch html/md files, run jekyll & reload BrowserSync
 */
function watch() {
	gulp.watch('src/styl/**/*.styl', runStylus);
	gulp.watch('src/js/**/*.js', runJs);
	gulp.watch('src/img/**/*.{jpg,png,gif,PNG,JPG}', runImagemin);
	gulp.watch(['*.html', 'about/index.html', 'blog/index.html', '_includes/*.html', '_layouts/*.html', '_posts/*'],
		gulp.series(jekyllBuild, reloadBrowserSync));
}

/**
 * Default task, running just `gulp` will compile the sass,
 * compile the jekyll site, launch BrowserSync & watch files.
 */
gulp.task('default', gulp.series(runJs, runStylus, gulp.series(jekyllBuild, doBrowserSync), watch));
gulp.task('compileJsStylus', gulp.series(runJs, runStylus));
<|endoftext|>


<commit_before>/* jshint -W079 */

// Load plugins
var gulp = require('gulp');

var webpack = require('gulp-webpack');
var webpackConfig = require('./webpack.config');
var connect = require('gulp-connect');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');
var livereload = require('gulp-livereload');
var del = require('del');
var runSequence = require('run-sequence');
var argv = require('yargs').argv;

var source = __dirname + '/src';
var dist = __dirname + '/dist';

// Local connect server for testing
gulp.task('connect', function() {
	connect.server({
		root: './',
		port: argv.port || 5000,
		hostname: '*', // to allow access to server from outside
		livereload: {
			port: 35731
		}
	});
});

// Html (for livereload)
gulp.task('html', function() {
    gulp.src('./**/*.html')
        .pipe(connect.reload());
});

// Webpack
gulp.task('webpack', function() {
	return gulp.src(source + '/tesserae.js')
		.pipe(webpack(webpackConfig))
		.pipe(gulp.dest(dist))
		.pipe(connect.reload());
});

// Uglify output
gulp.task('uglify', function() {
	return gulp.src(dist + '/js/**/*.js')
		.pipe(uglify())
		.pipe(gulp.dest(dist + '/js'));
});

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

// Lint
gulp.task('lint', function() {
    return gulp.src([
			source + '/js/**/*.js',
			'!' + source + '/js/vendor/**/*.js'
		])
	    .pipe(jshint())
	    .pipe(jshint.reporter(stylish));
});

// Watch
gulp.task('watch', function() {
	// Watch .js files
	gulp.watch(source + '/**/*.js', ['webpack']);
	// Watch .html files
	gulp.watch('./**/*.html', ['html']);
});

// Build (base build tasks, for dev)
gulp.task('build', function(callback) {
	var start = new Date().getTime();
	runSequence('clean', 'webpack', callback);
});

// Run in dev mode with static pages
gulp.task('run', function(callback) {
	runSequence('build', 'connect', 'watch', callback);
});

// Default task
gulp.task('default', function() {
	gulp.start('run');
});
<commit_msg>Updated gulpfile.js<commit_after>/* jshint -W079 */

// Load plugins
var gulp = require('gulp');

var webpack = require('gulp-webpack');
var webpackConfig = require('./webpack.config');
var connect = require('gulp-connect');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var uglify = require('gulp-uglify');
var livereload = require('gulp-livereload');
var del = require('del');
var runSequence = require('run-sequence');

var source = __dirname + '/src';
var dist = __dirname + '/dist';

// Local connect server for testing
gulp.task('connect', function() {
	connect.server({
		root: './',
		port: 5000,
		hostname: '*', // to allow access to server from outside
		livereload: {
			port: 35731
		}
	});
});

// Html (for livereload)
gulp.task('html', function() {
    gulp.src('./**/*.html')
        .pipe(connect.reload());
});

// Webpack
gulp.task('webpack', function() {
	return gulp.src(source + '/tesserae.js')
		.pipe(webpack(webpackConfig))
		.pipe(gulp.dest(dist))
		.pipe(connect.reload());
});

// Uglify output
gulp.task('uglify', function() {
	return gulp.src(dist + '/js/**/*.js')
		.pipe(uglify())
		.pipe(gulp.dest(dist + '/js'));
});

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

// Lint
gulp.task('lint', function() {
    return gulp.src([
			source + '/js/**/*.js',
			'!' + source + '/js/vendor/**/*.js'
		])
	    .pipe(jshint())
	    .pipe(jshint.reporter(stylish));
});

// Watch
gulp.task('watch', function() {
	// Watch .js files
	gulp.watch(source + '/**/*.js', ['webpack']);
	// Watch .html files
	gulp.watch('./**/*.html', ['html']);
});

// Build (base build tasks, for dev)
gulp.task('build', function(callback) {
	var start = new Date().getTime();
	runSequence('clean', 'webpack', callback);
});

// Run in dev mode with static pages
gulp.task('run', function(callback) {
	runSequence('build', 'connect', 'watch', callback);
});

// Default task
gulp.task('default', function() {
	gulp.start('run');
});
<|endoftext|>


<commit_before>'use strict';
// generated on 2017-03-03 using generator-gulp-bootstrap 0.0.4

var gulp = require('gulp');
var browserSync = require('browser-sync');
var pump = require('pump');
var reload = browserSync.reload;
var gutil = require('gulp-util');
var sassJson = require('gulp-sass-json');

// load plugins
var $ = require('gulp-load-plugins')();

gulp.task('styles', ['sassvars'], function () {
    return gulp.src('app/styles/main.scss')
        .pipe($.sass({ errLogToConsole: true }))
        .pipe($.autoprefixer('last 1 version'))
        .pipe(gulp.dest('app/styles'))
        .pipe(reload({ stream: true }))
        .pipe($.size());
});

gulp.task('sassvars', function () {
    return gulp.src('app/styles/base/_variables.scss')
        .pipe(sassJson())
        .pipe(gulp.dest('app/styles'));
});

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

    gulp.src('app/scripts/main/**/*.html')
        .pipe($.angularTemplatecache('templates.js', {
            module: 'vbr-style-guide'
        }))
        .pipe(gulp.dest('app/scripts/main'));

    return gulp.src(['app/scripts/main/**/*.module.js', 'app/scripts/main/**/*.js'])
        .pipe($.jshint())
        .pipe($.ngAnnotate({
            remove: true,
            add: true,
            single_quotes: true
        }))
        .pipe($.uglify())
        .pipe($.concat('main.js'))
        .pipe(gulp.dest('app/scripts'))
        .pipe($.jshint.reporter(require('jshint-stylish')))
        .pipe($.size());
});

gulp.task('html', ['styles', 'scripts'], function () {
    var jsFilter = $.filter('**/*.js');
    var cssFilter = $.filter('**/*.css');

    return gulp.src('app/*.html')
        .pipe($.useref.assets())
        .pipe(jsFilter)
        .pipe($.uglify())
        .pipe(jsFilter.restore())
        .pipe(cssFilter)
        .pipe($.csso())
        .pipe(cssFilter.restore())
        .pipe($.useref.restore())
        .pipe($.useref())
        .pipe(gulp.dest('styleguide'))
        .pipe($.size());
});

gulp.task('images', function () {
    return gulp.src('app/images/**/*')
        .pipe($.cache($.imagemin({
            optimizationLevel: 3,
            progressive: true,
            interlaced: true
        })))
        .pipe(gulp.dest('styleguide/images'))
        .pipe(reload({ stream: true, once: true }))
        .pipe($.size());
});

gulp.task('fonts', function () {
    var streamqueue = require('streamqueue');
    return streamqueue({ objectMode: true },
        $.bowerFiles(),
        gulp.src('app/fonts/**/*')
    )
        .pipe($.filter('**/*.{eot,svg,ttf,woff}'))
        .pipe($.flatten())
        .pipe(gulp.dest('styleguide/fonts'))
        .pipe($.size());
});

gulp.task('clean', function () {
    return gulp.src(['app/styles/main.css', 'app/styles/variables.json', 'styleguide', 'dist'], { read: false }).pipe($.clean());
});

gulp.task('serve', ['aigis'], function () {
    browserSync.init(null, {
        server: {
            baseDir: 'styleguide',
            directory: true
        },
        debugInfo: false,
        open: false
    }, function (err, bs) {
        require('opn')(bs.options.url);
        console.log('Started connect web server on ' + bs.options.url);
    });
});

// inject bower components
gulp.task('wiredep', function () {
    var wiredep = require('wiredep').stream;
    gulp.src('app/styles/*.scss')
        .pipe(wiredep({
            directory: 'bower_components'
        }))
        .pipe(gulp.dest('app/styles'));
    gulp.src('template_ejs/scripts.ejs')
        .pipe(wiredep({
            directory: 'bower_components',
            fileTypes: {
                html: {
                    replace: {
                        js: '<script src="<%- root%>{{filePath}}"></script>'
                    }
                }
            }
        }))
        .pipe(gulp.dest('template_ejs'));
});

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

    // watch for changes
    gulp.watch(['styleguide/*.html'], reload);
    gulp.watch(['aigis_config.yml', 'template_ejs/**/*', 'aigis_assets/**/*'], ['aigis', 'delayed-reload']);
    gulp.watch('app/styles/**/*.scss', ['styles', 'aigis']);
    gulp.watch(['app/scripts/main/**/*.js', 'app/scripts/**/*.html'], ['scripts', 'aigis']);
    gulp.watch('app/images/**/*', ['images']);
    gulp.watch('html/**/*', ['aigis']);
    gulp.watch('bower.json', ['wiredep', 'aigis']);
});

gulp.task("aigis", ['styles', 'scripts'], function () {
    gulp.src("./aigis_config.yml")
        .pipe($.aigis());
});

gulp.task('delayed-reload', function () {
    setTimeout(reload, 5000);
});

gulp.task('buildScripts',function(cb){
    pump([
            gulp.src(['app/scripts/main/*.module.js','app/scripts/main/*.controller.js',,'app/scripts/main/templates.js','app/scripts/main/*.constants.js','app/scripts/main/components/**/*.js']),
            $.ngAnnotate(),
            $.uglify(),
            $.concat('index.min.js'),
            gulp.dest('dist/scripts/')
        ],
        cb
    );
});

gulp.task('buildStyles',function(cb){
    pump([
        gulp.src('app/styles/**/*.scss'),
        $.size(),
        gulp.dest('dist/scss/')
    ],
    cb);
});

gulp.task('build', ['clean','buildScripts','buildStyles'], function () {
    return gulp.src('bower.json').pipe(gulp.dest('dist'));
});

gulp.task('default', ['clean'], function () {
    gulp.start('watch');
});
<commit_msg>Chore(Fix Build)<commit_after>'use strict';
// generated on 2017-03-03 using generator-gulp-bootstrap 0.0.4

var gulp = require('gulp');
var browserSync = require('browser-sync');
var pump = require('pump');
var reload = browserSync.reload;
var gutil = require('gulp-util');
var sassJson = require('gulp-sass-json');

// load plugins
var $ = require('gulp-load-plugins')();

gulp.task('styles', ['sassvars'], function () {
    return gulp.src('app/styles/main.scss')
        .pipe($.sass({ errLogToConsole: true }))
        .pipe($.autoprefixer('last 1 version'))
        .pipe(gulp.dest('app/styles'))
        .pipe(reload({ stream: true }))
        .pipe($.size());
});

gulp.task('sassvars', function () {
    return gulp.src('app/styles/base/_variables.scss')
        .pipe(sassJson())
        .pipe(gulp.dest('app/styles'));
});

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

    gulp.src('app/scripts/main/**/*.html')
        .pipe($.angularTemplatecache('templates.js', {
            module: 'vbr-style-guide'
        }))
        .pipe(gulp.dest('app/scripts/main'));

    return gulp.src(['app/scripts/main/**/*.module.js', 'app/scripts/main/**/*.js'])
        .pipe($.jshint())
        .pipe($.ngAnnotate({
            remove: true,
            add: true,
            single_quotes: true
        }))
        .pipe($.uglify())
        .pipe($.concat('main.js'))
        .pipe(gulp.dest('app/scripts'))
        .pipe($.jshint.reporter(require('jshint-stylish')))
        .pipe($.size());
});

gulp.task('html', ['styles', 'scripts'], function () {
    var jsFilter = $.filter('**/*.js');
    var cssFilter = $.filter('**/*.css');

    return gulp.src('app/*.html')
        .pipe($.useref.assets())
        .pipe(jsFilter)
        .pipe($.uglify())
        .pipe(jsFilter.restore())
        .pipe(cssFilter)
        .pipe($.csso())
        .pipe(cssFilter.restore())
        .pipe($.useref.restore())
        .pipe($.useref())
        .pipe(gulp.dest('styleguide'))
        .pipe($.size());
});

gulp.task('images', function () {
    return gulp.src('app/images/**/*')
        .pipe($.cache($.imagemin({
            optimizationLevel: 3,
            progressive: true,
            interlaced: true
        })))
        .pipe(gulp.dest('styleguide/images'))
        .pipe(reload({ stream: true, once: true }))
        .pipe($.size());
});

gulp.task('fonts', function () {
    var streamqueue = require('streamqueue');
    return streamqueue({ objectMode: true },
        $.bowerFiles(),
        gulp.src('app/fonts/**/*')
    )
        .pipe($.filter('**/*.{eot,svg,ttf,woff}'))
        .pipe($.flatten())
        .pipe(gulp.dest('styleguide/fonts'))
        .pipe($.size());
});

gulp.task('clean', function () {
    return gulp.src(['app/styles/main.css', 'app/styles/variables.json', 'styleguide', 'dist'], { read: false }).pipe($.clean());
});

gulp.task('serve', ['aigis'], function () {
    browserSync.init(null, {
        server: {
            baseDir: 'styleguide',
            directory: true
        },
        debugInfo: false,
        open: false
    }, function (err, bs) {
        require('opn')(bs.options.url);
        console.log('Started connect web server on ' + bs.options.url);
    });
});

// inject bower components
gulp.task('wiredep', function () {
    var wiredep = require('wiredep').stream;
    gulp.src('app/styles/*.scss')
        .pipe(wiredep({
            directory: 'bower_components'
        }))
        .pipe(gulp.dest('app/styles'));
    gulp.src('template_ejs/scripts.ejs')
        .pipe(wiredep({
            directory: 'bower_components',
            fileTypes: {
                html: {
                    replace: {
                        js: '<script src="<%- root%>{{filePath}}"></script>'
                    }
                }
            }
        }))
        .pipe(gulp.dest('template_ejs'));
});

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

    // watch for changes
    gulp.watch(['styleguide/*.html'], reload);
    gulp.watch(['aigis_config.yml', 'template_ejs/**/*', 'aigis_assets/**/*'], ['aigis', 'delayed-reload']);
    gulp.watch('app/styles/**/*.scss', ['styles', 'aigis']);
    gulp.watch(['app/scripts/main/**/*.js', 'app/scripts/**/*.html'], ['scripts', 'aigis']);
    gulp.watch('app/images/**/*', ['images']);
    gulp.watch('html/**/*', ['aigis']);
    gulp.watch('bower.json', ['wiredep', 'aigis']);
});

gulp.task("aigis", ['styles', 'scripts'], function () {
    gulp.src("./aigis_config.yml")
        .pipe($.aigis());
});

gulp.task('delayed-reload', function () {
    setTimeout(reload, 5000);
});

gulp.task('buildScripts',function(cb){
    pump([
            gulp.src(['app/scripts/main/*.module.js','app/scripts/main/*.controller.js','app/scripts/main/templates.js','app/scripts/main/*.constants.js','app/scripts/main/components/**/*.js']),
            $.ngAnnotate(),
            $.uglify(),
            $.concat('index.min.js'),
            gulp.dest('dist/scripts/')
        ],
        cb
    );
});

gulp.task('buildStyles',function(cb){
    pump([
        gulp.src('app/styles/**/*.scss'),
        $.size(),
        gulp.dest('dist/scss/')
    ],
    cb);
});

gulp.task('build', ['clean','buildScripts','buildStyles'], function () {
    return gulp.src('bower.json').pipe(gulp.dest('dist'));
});

gulp.task('default', ['clean'], function () {
    gulp.start('watch');
});
<|endoftext|>


<commit_before>'use strict';
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var hbsfy = require('hbsfy');
var opt = {
  build: 'build',
  app: {
    src: './src/js/app.js',
    dest: 'app.js'
  },
  vendors: 'vendors.js',

  jsAssets: [
    'src/js/**/*.*',
  ],

  cssAssets: [
    'src/css/bootstrap.min.css',
    'src/css/bootstrap-theme.min.css'
  ],

  fontAssets: [
    'src/fonts/*'
  ]
};

gulp.task('assets', ['assets:css', 'assets:fonts']);

gulp.task("assets:css", function() {
  return gulp.src(opt.cssAssets)
    .pipe(gulp.dest(opt.build + '/css'));
});

gulp.task("assets:fonts", function() {
  return gulp.src(opt.fontAssets)
    .pipe(gulp.dest(opt.build + '/fonts'));
});

gulp.task('build:js', [
  'browserify:app',
  'browserify:vendors'
]);

gulp.task('browserify:app', ['browserify:vendors'], function() {
  var bundleStream = browserify(opt.app.src);

  bundleStream
    .external('pouchdb')
    .external('backbone')
    .external('jquery')
    .external('backbone-pouch')
    .transform('hbsfy')
    .bundle()
    .pipe(source(opt.app.dest))
    .pipe(gulp.dest(opt.build + '/js'));

  return bundleStream;

});

gulp.task('browserify:vendors', function() {
  var vendorStream = browserify();
  vendorStream
    .require('backbone')
    .require('backbone-pouch')
    .require('jquery')
    .require('pouchdb')
    .bundle()
    .pipe(source(opt.vendors))
    .pipe(gulp.dest(opt.build + '/js'));

  return vendorStream;
});

gulp.task('watch', function() {
  gulp.watch(opt.jsAssets, ['build:js']);
});

gulp.task('default', ['build:js', 'assets']);
<commit_msg>Add new task for node-webkit<commit_after>'use strict';
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var hbsfy = require('hbsfy');
var opt = {
  build: 'build',
  app: {
    src: './src/js/app.js',
    dest: 'app.js'
  },

  copy: [
    './src/webkit/**/*.*'
  ],

  vendors: 'vendors.js',

  jsAssets: [
    'src/js/**/*.*',
  ],

  cssAssets: [
    'src/css/bootstrap.min.css',
    'src/css/bootstrap-theme.min.css'
  ],

  fontAssets: [
    'src/fonts/*'
  ]
};

gulp.task('assets', ['assets:css', 'assets:fonts']);

gulp.task('copy', function() {
  return gulp.src(opt.copy)
    .pipe(gulp.dest(opt.build + '/js'));
});

gulp.task("assets:css", function() {
  return gulp.src(opt.cssAssets)
    .pipe(gulp.dest(opt.build + '/css'));
});

gulp.task("assets:fonts", function() {
  return gulp.src(opt.fontAssets)
    .pipe(gulp.dest(opt.build + '/fonts'));
});

gulp.task('build:js', [
  'browserify:app',
  'browserify:vendors'
]);

gulp.task('browserify:app', ['browserify:vendors'], function() {
  var bundleStream = browserify(opt.app.src);

  bundleStream
    .external('pouchdb')
    .external('backbone')
    .external('jquery')
    .external('backbone-pouch')
    .transform('hbsfy')
    .bundle()
    .pipe(source(opt.app.dest))
    .pipe(gulp.dest(opt.build + '/js'));

  return bundleStream;

});

gulp.task('browserify:vendors', function() {
  var vendorStream = browserify();
  vendorStream
    .require('backbone')
    .require('backbone-pouch')
    .require('jquery')
    .require('pouchdb')
    .bundle()
    .pipe(source(opt.vendors))
    .pipe(gulp.dest(opt.build + '/js'));

  return vendorStream;
});

gulp.task('watch', function() {
  gulp.watch(opt.jsAssets, ['build:js']);
});

gulp.task('default', ['build:js', 'assets', 'copy']);
gulp.task('dev', ['build:js', 'assests']);
<|endoftext|>


<commit_before>'use strict';

/**
 * Module dependencies.
 */
var _ = require('lodash'),
	defaultAssets = require('./config/assets/default'),
	testAssets = require('./config/assets/test'),
	gulp = require('gulp'),
	gulpLoadPlugins = require('gulp-load-plugins'),
	runSequence = require('run-sequence'),
	plugins = gulpLoadPlugins();

// Set NODE_ENV to 'test'
gulp.task('env:test', function () {
	process.env.NODE_ENV = 'test';
});

// Set NODE_ENV to 'development'
gulp.task('env:dev', function () {
	process.env.NODE_ENV = 'development';
});

// Set NODE_ENV to 'production'
gulp.task('env:prod', function () {
	process.env.NODE_ENV = 'production';
});

// Nodemon task
gulp.task('nodemon', function () {
	return plugins.nodemon({
		script: 'server.js',
		nodeArgs: ['--debug'],
		ext: 'js,html',
		watch: _.union(defaultAssets.server.views, defaultAssets.server.allJS, defaultAssets.server.config)
	});
});

// Watch Files For Changes
gulp.task('watch', function() {
	// Start livereload
	plugins.livereload.listen();

	// Add watch rules
	gulp.watch(defaultAssets.server.gulpConfig, ['jshint']);
	gulp.watch(defaultAssets.server.views).on('change', plugins.livereload.changed);
	gulp.watch(defaultAssets.server.allJS, ['jshint']).on('change', plugins.livereload.changed);
	gulp.watch(defaultAssets.client.views).on('change', plugins.livereload.changed);
	gulp.watch(defaultAssets.client.js, ['jshint']).on('change', plugins.livereload.changed);
	gulp.watch(defaultAssets.client.css, ['csslint']).on('change', plugins.livereload.changed);
	gulp.watch(defaultAssets.client.sass, ['sass', 'csslint']).on('change', plugins.livereload.changed);
	gulp.watch(defaultAssets.client.less, ['less', 'csslint']).on('change', plugins.livereload.changed);
});

// CSS linting task
gulp.task('csslint', function (done) {
	return gulp.src(defaultAssets.client.css)
		.pipe(plugins.csslint('.csslintrc'))
		.pipe(plugins.csslint.reporter())
		.pipe(plugins.csslint.reporter(function (file) {
			if (!file.csslint.errorCount) {
				done();
			}
		}));
});

// JS linting task
gulp.task('jshint', function () {
	return gulp.src(_.union(defaultAssets.server.gulpConfig, defaultAssets.server.allJS, defaultAssets.client.js, testAssets.tests.server, testAssets.tests.client, testAssets.tests.e2e))
		.pipe(plugins.jshint())
		.pipe(plugins.jshint.reporter('default'))
		.pipe(plugins.jshint.reporter('fail'));
});

// JS minifying task
gulp.task('uglify', function () {
	return gulp.src(defaultAssets.client.js)
		.pipe(plugins.ngAnnotate())
		.pipe(plugins.uglify({
			mangle: false
		}))
		.pipe(plugins.concat('application.min.js'))
		.pipe(gulp.dest('public/dist'));
});

// CSS minifying task
gulp.task('cssmin', function () {
	return gulp.src(defaultAssets.client.css)
		.pipe(plugins.cssmin())
		.pipe(plugins.concat('application.min.css'))
		.pipe(gulp.dest('public/dist'));
});

// Sass task
gulp.task('sass', function () {
	return gulp.src(defaultAssets.client.sass)
		.pipe(plugins.sass())
		.pipe(plugins.rename(function (path) {
			path.dirname = path.dirname.replace('/scss', '/css');
		}))
		.pipe(gulp.dest('./modules/'));
});

// Less task
gulp.task('less', function () {
	return gulp.src(defaultAssets.client.less)
		.pipe(plugins.less())
		.pipe(plugins.rename(function (path) {
			path.dirname = path.dirname.replace('/less', '/css');
		}))
		.pipe(gulp.dest('./modules/'));
});

// Mocha tests task
gulp.task('mocha', function (done) {
	// Open mongoose connections
	var mongoose = require('./config/lib/mongoose.js');
	var error;

	// Connect mongoose
	mongoose.connect(function() {
		// Run the tests
		gulp.src(testAssets.tests.server)
			.pipe(plugins.mocha({
				reporter: 'spec'
			}))
			.on('error', function (err) {
				// If an error occurs, save it
				error = err;
			})
			.on('end', function() {
				// When the tests are done, disconnect mongoose and pass the error state back to gulp
				mongoose.disconnect(function() {
					done(error);
				});
			});
	});

});

// Karma test runner task
gulp.task('karma', function (done) {
	return gulp.src([])
		.pipe(plugins.karma({
			configFile: 'karma.conf.js',
			action: 'run',
			singleRun: true
		}));
});

// Selenium standalone WebDriver update task
gulp.task('webdriver-update', plugins.protractor.webdriver_update);

// Protractor test runner task
gulp.task('protractor', function () {
	gulp.src([])
		.pipe(plugins.protractor.protractor({
			configFile: 'protractor.conf.js'
		}))
		.on('error', function (e) {
			throw e;
		});
});

// Lint CSS and JavaScript files.
gulp.task('lint', function(done) {
	runSequence('less', 'sass', ['csslint', 'jshint'], done);
});

// Lint project files and minify them into two production files.
gulp.task('build', function(done) {
	runSequence('env:dev' ,'lint', ['uglify', 'cssmin'], done);
});

// Run the project tests
gulp.task('test', function(done) {
	runSequence('env:test', ['karma', 'mocha'], done);
});

// Run the project in development mode
gulp.task('default', function(done) {
	runSequence('env:dev', 'lint', ['nodemon', 'watch'], done);
});

// Run the project in debug mode
gulp.task('debug', function(done) {
	runSequence('env:dev', 'lint', ['nodemon', 'watch'], done);
});

// Run the project in production mode
gulp.task('prod', function(done) {
	runSequence('build', 'lint', ['nodemon', 'watch'], done);
});
<commit_msg>BUG: Path separator support for windows.<commit_after>'use strict';

/**
 * Module dependencies.
 */
var _ = require('lodash'),
	defaultAssets = require('./config/assets/default'),
	testAssets = require('./config/assets/test'),
	gulp = require('gulp'),
	gulpLoadPlugins = require('gulp-load-plugins'),
	runSequence = require('run-sequence'),
	plugins = gulpLoadPlugins(),
	path = require('path');

// Set NODE_ENV to 'test'
gulp.task('env:test', function () {
	process.env.NODE_ENV = 'test';
});

// Set NODE_ENV to 'development'
gulp.task('env:dev', function () {
	process.env.NODE_ENV = 'development';
});

// Set NODE_ENV to 'production'
gulp.task('env:prod', function () {
	process.env.NODE_ENV = 'production';
});

// Nodemon task
gulp.task('nodemon', function () {
	return plugins.nodemon({
		script: 'server.js',
		nodeArgs: ['--debug'],
		ext: 'js,html',
		watch: _.union(defaultAssets.server.views, defaultAssets.server.allJS, defaultAssets.server.config)
	});
});

// Watch Files For Changes
gulp.task('watch', function() {
	// Start livereload
	plugins.livereload.listen();

	// Add watch rules
	gulp.watch(defaultAssets.server.gulpConfig, ['jshint']);
	gulp.watch(defaultAssets.server.views).on('change', plugins.livereload.changed);
	gulp.watch(defaultAssets.server.allJS, ['jshint']).on('change', plugins.livereload.changed);
	gulp.watch(defaultAssets.client.views).on('change', plugins.livereload.changed);
	gulp.watch(defaultAssets.client.js, ['jshint']).on('change', plugins.livereload.changed);
	gulp.watch(defaultAssets.client.css, ['csslint']).on('change', plugins.livereload.changed);
	gulp.watch(defaultAssets.client.sass, ['sass', 'csslint']).on('change', plugins.livereload.changed);
	gulp.watch(defaultAssets.client.less, ['less', 'csslint']).on('change', plugins.livereload.changed);
});

// CSS linting task
gulp.task('csslint', function (done) {
	return gulp.src(defaultAssets.client.css)
		.pipe(plugins.csslint('.csslintrc'))
		.pipe(plugins.csslint.reporter())
		.pipe(plugins.csslint.reporter(function (file) {
			if (!file.csslint.errorCount) {
				done();
			}
		}));
});

// JS linting task
gulp.task('jshint', function () {
	return gulp.src(_.union(defaultAssets.server.gulpConfig, defaultAssets.server.allJS, defaultAssets.client.js, testAssets.tests.server, testAssets.tests.client, testAssets.tests.e2e))
		.pipe(plugins.jshint())
		.pipe(plugins.jshint.reporter('default'))
		.pipe(plugins.jshint.reporter('fail'));
});

// JS minifying task
gulp.task('uglify', function () {
	return gulp.src(defaultAssets.client.js)
		.pipe(plugins.ngAnnotate())
		.pipe(plugins.uglify({
			mangle: false
		}))
		.pipe(plugins.concat('application.min.js'))
		.pipe(gulp.dest('public/dist'));
});

// CSS minifying task
gulp.task('cssmin', function () {
	return gulp.src(defaultAssets.client.css)
		.pipe(plugins.cssmin())
		.pipe(plugins.concat('application.min.css'))
		.pipe(gulp.dest('public/dist'));
});

// Sass task
gulp.task('sass', function () {
	return gulp.src(defaultAssets.client.sass)
		.pipe(plugins.sass())
		.pipe(plugins.rename(function (file) {
			file.dirname = file.dirname.replace(path.sep + 'scss', path.sep + 'css');
		}))
		.pipe(gulp.dest('./modules/'));
});

// Less task
gulp.task('less', function () {
	return gulp.src(defaultAssets.client.less)
		.pipe(plugins.less())
		.pipe(plugins.rename(function (file) {
			file.dirname = file.dirname.replace(path.sep + 'less', path.sep + 'css');
		}))
		.pipe(gulp.dest('./modules/'));
});

// Mocha tests task
gulp.task('mocha', function (done) {
	// Open mongoose connections
	var mongoose = require('./config/lib/mongoose.js');
	var error;

	// Connect mongoose
	mongoose.connect(function() {
		// Run the tests
		gulp.src(testAssets.tests.server)
			.pipe(plugins.mocha({
				reporter: 'spec'
			}))
			.on('error', function (err) {
				// If an error occurs, save it
				error = err;
			})
			.on('end', function() {
				// When the tests are done, disconnect mongoose and pass the error state back to gulp
				mongoose.disconnect(function() {
					done(error);
				});
			});
	});

});

// Karma test runner task
gulp.task('karma', function (done) {
	return gulp.src([])
		.pipe(plugins.karma({
			configFile: 'karma.conf.js',
			action: 'run',
			singleRun: true
		}));
});

// Selenium standalone WebDriver update task
gulp.task('webdriver-update', plugins.protractor.webdriver_update);

// Protractor test runner task
gulp.task('protractor', function () {
	gulp.src([])
		.pipe(plugins.protractor.protractor({
			configFile: 'protractor.conf.js'
		}))
		.on('error', function (e) {
			throw e;
		});
});

// Lint CSS and JavaScript files.
gulp.task('lint', function(done) {
	runSequence('less', 'sass', ['csslint', 'jshint'], done);
});

// Lint project files and minify them into two production files.
gulp.task('build', function(done) {
	runSequence('env:dev' ,'lint', ['uglify', 'cssmin'], done);
});

// Run the project tests
gulp.task('test', function(done) {
	runSequence('env:test', ['karma', 'mocha'], done);
});

// Run the project in development mode
gulp.task('default', function(done) {
	runSequence('env:dev', 'lint', ['nodemon', 'watch'], done);
});

// Run the project in debug mode
gulp.task('debug', function(done) {
	runSequence('env:dev', 'lint', ['nodemon', 'watch'], done);
});

// Run the project in production mode
gulp.task('prod', function(done) {
	runSequence('build', 'lint', ['nodemon', 'watch'], done);
});
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp'),
  $ = require('gulp-load-plugins')(),
  lost = require('lost'),
  autoprefixer = require('autoprefixer'),
  lazypipe = require('lazypipe'),
  // @todo Rename production server environment variable ;)
  is_production = process.env.COMPASS_PRODUCTION === 'true',
  path = require('path'),
  theme_path = path.join(__dirname, 'htdocs', 'themes', 'MYTHEME');

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

  var csslintTasks = lazypipe()
    // @todo Custom reporter to $.notify() user if any problems
    .pipe($.csslint, 'htdocs/.csslintrc')
    .pipe($.csslint.reporter);

  return gulp.src(path.join(theme_path, 'less', 'style.less')
    // Catch any errors to prevent them from crashing gulp
    .pipe($.plumber({
      errorHandler: $.notify.onError({
        message: 'Error: <%= error.message %>',
        title: '<%= error.plugin %>'
      })
    }))
    //.pipe($.debug())
    // Start source maps processing
    .pipe($.if(!is_production, $.sourcemaps.init()))
    // Convert scss to css
    .pipe($.less({
      paths: [ theme_path, 'less' ]
    }))
    .pipe($.postcss([
      lost(),
      autoprefixer({
        browsers: ['> 1% in DE', '> 1% in AT', '> 1% in CH', 'last 2 versions', 'Firefox ESR']
      })]
    ))
    // Write source maps
    .pipe($.if(!is_production, $.sourcemaps.write()))
    // Lint css using Drupal rules
    // @todo Find a way to not use linting on bootstrap css
    //.pipe($.if(!is_production, csslintTasks()))
    // Write to destination
    .pipe(gulp.dest(path.join(theme_path, 'css')))
    // Push to livereload
    .pipe($.if(!is_production, $.livereload()));
});

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

  var eslintTasks = lazypipe()
    // @todo Custom reporter to $.notify() user if any problems
    .pipe($.eslint)
    .pipe($.eslint.format);

  return gulp.src('htdocs/{modules,themes}/**/*.js', { base: 'htdocs' })
    // Filter out third-party and minified scripts before linting
    .pipe($.filter(['**/*', '!**/{contrib,vendor}/**', '!**/*.min.js']))
    // Catch any errors to prevent them from crashing gulp
    .pipe($.plumber({
      errorHandler: $.notify.onError({
        message: 'Error: <%= error.message %>',
        title: '<%= error.plugin %>'
      })
    }))
    .pipe($.uglify())
    .pipe($.rename({
      extname: '.min.js'
    }))
    .pipe(gulp.dest('htdocs'))
    //.pipe($.if(!is_production, eslint()))
    // Push to livereload
    .pipe($.if(!is_production, $.livereload()));
});

//gulp.task('images', function () {
//  return gulp.src('htdocs/{modules,themes}/**/*.{png,jpg,jpeg,gif}', { base: 'htdocs' })
//    .pipe($.cache($.imagemin({
//      progressive: true,
//      interlaced: true,
//      svgoPlugins: [{removeViewBox: false}]
//    })))
//    .pipe(gulp.dest('htdocs'));
//});

gulp.task('build', function () {
  gulp.start('styles');
  //gulp.start('scripts');
  //gulp.start('images');
});

gulp.task('watch', function () {
  $.livereload.listen();

  // Watch for modifications and run tasks
  gulp.watch('htdocs/{modules,themes}/**/*.less', ['styles']);
  //gulp.watch('htdocs/{modules,themes}/**/*.js', ['scripts']);
  //gulp.watch('htdocs/{modules,themes}/**/*.{png,jpg,jpeg,gif}', ['images']);
});

gulp.task('clean', function (done) {
  //gulp.src('htdocs/{modules,themes}/**/*.scss', { read: false, base: 'htdocs' })
  //  @todo Delete generated .css files, but no other
  //  .pipe();
  //return $.cache.clearAll(done);
});

gulp.task('default', ['build'], function () {
  gulp.start('watch');
});
<commit_msg>Bugfix<commit_after>'use strict';

var gulp = require('gulp'),
  $ = require('gulp-load-plugins')(),
  lost = require('lost'),
  autoprefixer = require('autoprefixer'),
  lazypipe = require('lazypipe'),
  // @todo Rename production server environment variable ;)
  is_production = process.env.COMPASS_PRODUCTION === 'true',
  path = require('path'),
  theme_path = path.join(__dirname, 'htdocs', 'themes', 'MYTHEME');

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

  var csslintTasks = lazypipe()
    // @todo Custom reporter to $.notify() user if any problems
    .pipe($.csslint, 'htdocs/.csslintrc')
    .pipe($.csslint.reporter);

  return gulp.src(path.join(theme_path, 'less', 'style.less'))
    // Catch any errors to prevent them from crashing gulp
    .pipe($.plumber({
      errorHandler: $.notify.onError({
        message: 'Error: <%= error.message %>',
        title: '<%= error.plugin %>'
      })
    }))
    //.pipe($.debug())
    // Start source maps processing
    .pipe($.if(!is_production, $.sourcemaps.init()))
    // Convert scss to css
    .pipe($.less({
      paths: [ theme_path, 'less' ]
    }))
    .pipe($.postcss([
      lost(),
      autoprefixer({
        browsers: ['> 1% in DE', '> 1% in AT', '> 1% in CH', 'last 2 versions', 'Firefox ESR']
      })]
    ))
    // Write source maps
    .pipe($.if(!is_production, $.sourcemaps.write()))
    // Lint css using Drupal rules
    // @todo Find a way to not use linting on bootstrap css
    //.pipe($.if(!is_production, csslintTasks()))
    // Write to destination
    .pipe(gulp.dest(path.join(theme_path, 'css')))
    // Push to livereload
    .pipe($.if(!is_production, $.livereload()));
});

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

  var eslintTasks = lazypipe()
    // @todo Custom reporter to $.notify() user if any problems
    .pipe($.eslint)
    .pipe($.eslint.format);

  return gulp.src('htdocs/{modules,themes}/**/*.js', { base: 'htdocs' })
    // Filter out third-party and minified scripts before linting
    .pipe($.filter(['**/*', '!**/{contrib,vendor}/**', '!**/*.min.js']))
    // Catch any errors to prevent them from crashing gulp
    .pipe($.plumber({
      errorHandler: $.notify.onError({
        message: 'Error: <%= error.message %>',
        title: '<%= error.plugin %>'
      })
    }))
    .pipe($.uglify())
    .pipe($.rename({
      extname: '.min.js'
    }))
    .pipe(gulp.dest('htdocs'))
    //.pipe($.if(!is_production, eslint()))
    // Push to livereload
    .pipe($.if(!is_production, $.livereload()));
});

//gulp.task('images', function () {
//  return gulp.src('htdocs/{modules,themes}/**/*.{png,jpg,jpeg,gif}', { base: 'htdocs' })
//    .pipe($.cache($.imagemin({
//      progressive: true,
//      interlaced: true,
//      svgoPlugins: [{removeViewBox: false}]
//    })))
//    .pipe(gulp.dest('htdocs'));
//});

gulp.task('build', function () {
  gulp.start('styles');
  //gulp.start('scripts');
  //gulp.start('images');
});

gulp.task('watch', function () {
  $.livereload.listen();

  // Watch for modifications and run tasks
  gulp.watch('htdocs/{modules,themes}/**/*.less', ['styles']);
  //gulp.watch('htdocs/{modules,themes}/**/*.js', ['scripts']);
  //gulp.watch('htdocs/{modules,themes}/**/*.{png,jpg,jpeg,gif}', ['images']);
});

gulp.task('clean', function (done) {
  //gulp.src('htdocs/{modules,themes}/**/*.scss', { read: false, base: 'htdocs' })
  //  @todo Delete generated .css files, but no other
  //  .pipe();
  //return $.cache.clearAll(done);
});

gulp.task('default', ['build'], function () {
  gulp.start('watch');
});
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var browserSync = require('browser-sync');

var AUTOPREFIXER_BROWSERS = [
  'ie >= 10',
  'ie_mob >= 10',
  'ff >= 30',
  'chrome >= 34',
  'safari >= 7',
  'opera >= 23',
  'ios >= 7',
  'android >= 4.4',
  'bb >= 10'
];

gulp.task('styles', function () {
  return gulp.src('app/*.less')
    .pipe($.less({
      paths: ['app']
    }))
    .pipe($.autoprefixer({browsers: AUTOPREFIXER_BROWSERS}))
    .pipe(gulp.dest('dist'));
});

gulp.task('jade', function () {
  return gulp.src('app/index.jade')
    //.pipe($.changed('app', {extension: '.jade'}))
    .pipe($.jade({
      locals: {}
    }))
    .pipe(gulp.dest('dist'));
});

gulp.task('serve', ['jade', 'styles'], function (cb) {
  browserSync({
    files: '{.tmp,dist}/**/*',
    server: {
      baseDir: ['dist']
    },
    open: true
  }, cb);
  gulp.watch(['app/**/*.jade'], ['jade',  browserSync.reload]);
  gulp.watch(['app/**/*.less'], ['styles', browserSync.reload]);
});
<commit_msg>add deploy task<commit_after>'use strict';

var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var browserSync = require('browser-sync');

var AUTOPREFIXER_BROWSERS = [
  'ie >= 10',
  'ie_mob >= 10',
  'ff >= 30',
  'chrome >= 34',
  'safari >= 7',
  'opera >= 23',
  'ios >= 7',
  'android >= 4.4',
  'bb >= 10'
];

gulp.task('styles', function () {
  return gulp.src('app/*.less')
    .pipe($.less({
      paths: ['app']
    }))
    .pipe($.autoprefixer({browsers: AUTOPREFIXER_BROWSERS}))
    .pipe(gulp.dest('dist'));
});

gulp.task('jade', function () {
  return gulp.src('app/index.jade')
    //.pipe($.changed('app', {extension: '.jade'}))
    .pipe($.jade({
      locals: {}
    }))
    .pipe(gulp.dest('dist'));
});

gulp.task('serve', ['jade', 'styles'], function (cb) {
  browserSync({
    files: '{.tmp,dist}/**/*',
    server: {
      baseDir: ['dist']
    },
    open: true
  }, cb);
  gulp.watch(['app/**/*.jade'], ['jade',  browserSync.reload]);
  gulp.watch(['app/**/*.less'], ['styles', browserSync.reload]);
});

// Deployment to GitHub using git.
gulp.task('deploy', ['default'], function (done) {
  runSequence('deploy:commit', 'deploy:push', done);
});

// Commit changes to production build locally.
gulp.task('deploy:commit', function (done) {
  var msg, im = process.argv.indexOf('-m');
  if (im >= 0) {
    msg = process.argv.slice(im, im + 2)[1];
  }
  msg = msg || 'Production build';
  var cmd = ["git add .", "git commit -m '" + msg + "'", "git status"];
  exec(cmd.join(' && '), {cwd: path.join(process.cwd(), 'dist')}, function (err, stdout, stderr) {
    if (!/working directory clean/m.test(stdout)) {
      console.log('--- ERROR log ---\n' + stderr);
      console.log('--- STDOUT log ---\n' + stdout);
      throw err || new Error('deploy:commit');
    }
    done();
  });
});

// Push changes to remote (actual deployment).
gulp.task('deploy:push', function (done) {
  var cwd = path.join(process.cwd(), 'dist');
  var args = ['push', '-u', 'origin', 'gh-pages'];
  spawn('git', args, {cwd: cwd, stdio: 'inherit'}).on('close', function (code) {
    if (code !== 0) {
      throw new Error('deploy:push exit code is ' + code);
    }
    done();
  });
});

gulp.task('default', ['jade', 'styles'], function (cb) {
  cb();
});
<|endoftext|>


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

var browserSync = require('browser-sync').create();
var del = require('del');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var csso = require('gulp-csso');
var twig = require('gulp-twig');
var fs = require('fs');

// a task to delete all css files in dist folder
gulp.task('css:clean', function(){
    return del([
        'dist/*.css',
        'dist/*.map'
    ], { force: true });
});

// CSS compilation (also deletes css files first using previously defined task)
gulp.task('css:compile', ['css:clean'], function(){
    return gulp
        .src('src/scss/index.scss') // this is the source of for compilation
        .pipe(sass().on('error', sass.logError)) // compile sass to css and also tell us about a problem if happens
        .pipe(sourcemaps.init()) // initalizes a sourcemap
        .pipe(postcss([autoprefixer( // supported browsers (from Bootstrap 4 beta: https://github.com/twbs/bootstrap/blob/v4-dev/build/postcss.config.js)
            //
            // Official browser support policy:
            // https://v4-alpha.getbootstrap.com/getting-started/browsers-devices/#supported-browsers
            //
            'Chrome >= 45', // Exact version number here is kinda arbitrary
            'Firefox ESR',
            // Note: Edge versions in Autoprefixer & Can I Use refer to the EdgeHTML rendering engine version,
            // NOT the Edge app version shown in Edge's "About" screen.
            // For example, at the time of writing, Edge 20 on an up-to-date system uses EdgeHTML 12.
            // See also https://github.com/Fyrd/caniuse/issues/1928
            'Edge >= 12',
            'Explorer >= 10',
            // Out of leniency, we prefix these 1 version further back than the official policy.
            'iOS >= 9',
            'Safari >= 9',
            // The following remain NOT officially supported, but we're lenient and include their prefixes to avoid severely breaking in them.
            'Android >= 4.4',
            'Opera >= 30'
        ), require('postcss-flexbugs-fixes')]))
        .pipe(csso()) // compresses CSS
        .pipe(sourcemaps.write('.')) // writes the sourcemap
        .pipe(gulp.dest('./dist')) // destination of the resulting css
        .pipe(browserSync.stream()); // tell browsersync to reload CSS (injects compiled CSS)
});

// delete all html files in dist folder
gulp.task('html:clean', function(){
    return del('dist/**/*.html', { force: true });
});

// HTML compilation from templates
gulp.task('html:compile', ['html:clean'], function(){
    return gulp.src('src/templates/**/[^_]*.twig')
    // compile twig templates to html files
        .pipe(twig({ data: JSON.parse(fs.readFileSync('src/templates/data.json')) })) // import from data.json
        .pipe(gulp.dest('./dist/')) // where to put compiled html
        .on('end', function(){ // after compilation finishes…
            browserSync.reload() // … tell Browsersync to reload
        });
});

// delete all files from src except css
gulp.task('static:clean', function(){
    return del([
        'dist/**/*',
        '!dist/**/*.html',
        '!dist/**/*.css',
        '!dist/**/*.map'
    ], { force: true });
});

// copy everything except scss from src folder
gulp.task('static:copy', ['static:clean'], function(){
    return gulp.src('src/static/**/*')
        .pipe(gulp.dest('dist'))
        .on('end', function(){ // after copying finishes…
            browserSync.reload() // … tell Browsersync to reload
        });
});

// build everything
gulp.task('build', ['css:compile', 'html:compile', 'static:copy']);

// development with automatic refreshing
gulp.task('develop', ['build'], function(){
    browserSync.init({ // initalize Browsersync
        // set what files be served
        server: {
            baseDir: 'dist' // serve from this folder
        }
    });
    gulp.watch('src/scss/**/*', ['css:compile']); // watch for changes in scss
    gulp.watch('src/templates/**/*', ['html:compile']); // watch for changes in templates
    gulp.watch('src/static/**/*', ['static:copy']); // watch for changes in static files
});

// set develop as a default task (gulp runs this when you don't specify a task)
gulp.task('default', ['develop']);
<commit_msg>serving html files without extension<commit_after>// load everything
var gulp = require('gulp');

var browserSync = require('browser-sync').create();
var del = require('del');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var csso = require('gulp-csso');
var twig = require('gulp-twig');
var fs = require('fs');

// a task to delete all css files in dist folder
gulp.task('css:clean', function(){
    return del([
        'dist/*.css',
        'dist/*.map'
    ], { force: true });
});

// CSS compilation (also deletes css files first using previously defined task)
gulp.task('css:compile', ['css:clean'], function(){
    return gulp
        .src('src/scss/index.scss') // this is the source of for compilation
        .pipe(sass().on('error', sass.logError)) // compile sass to css and also tell us about a problem if happens
        .pipe(sourcemaps.init()) // initalizes a sourcemap
        .pipe(postcss([autoprefixer( // supported browsers (from Bootstrap 4 beta: https://github.com/twbs/bootstrap/blob/v4-dev/build/postcss.config.js)
            //
            // Official browser support policy:
            // https://v4-alpha.getbootstrap.com/getting-started/browsers-devices/#supported-browsers
            //
            'Chrome >= 45', // Exact version number here is kinda arbitrary
            'Firefox ESR',
            // Note: Edge versions in Autoprefixer & Can I Use refer to the EdgeHTML rendering engine version,
            // NOT the Edge app version shown in Edge's "About" screen.
            // For example, at the time of writing, Edge 20 on an up-to-date system uses EdgeHTML 12.
            // See also https://github.com/Fyrd/caniuse/issues/1928
            'Edge >= 12',
            'Explorer >= 10',
            // Out of leniency, we prefix these 1 version further back than the official policy.
            'iOS >= 9',
            'Safari >= 9',
            // The following remain NOT officially supported, but we're lenient and include their prefixes to avoid severely breaking in them.
            'Android >= 4.4',
            'Opera >= 30'
        ), require('postcss-flexbugs-fixes')]))
        .pipe(csso()) // compresses CSS
        .pipe(sourcemaps.write('.')) // writes the sourcemap
        .pipe(gulp.dest('./dist')) // destination of the resulting css
        .pipe(browserSync.stream()); // tell browsersync to reload CSS (injects compiled CSS)
});

// delete all html files in dist folder
gulp.task('html:clean', function(){
    return del('dist/**/*.html', { force: true });
});

// HTML compilation from templates
gulp.task('html:compile', ['html:clean'], function(){
    return gulp.src('src/templates/**/[^_]*.twig')
    // compile twig templates to html files
        .pipe(twig({ data: JSON.parse(fs.readFileSync('src/templates/data.json')) })) // import from data.json
        .pipe(gulp.dest('./dist/')) // where to put compiled html
        .on('end', function(){ // after compilation finishes…
            browserSync.reload() // … tell Browsersync to reload
        });
});

// delete all files from src except css
gulp.task('static:clean', function(){
    return del([
        'dist/**/*',
        '!dist/**/*.html',
        '!dist/**/*.css',
        '!dist/**/*.map'
    ], { force: true });
});

// copy everything except scss from src folder
gulp.task('static:copy', ['static:clean'], function(){
    return gulp.src('src/static/**/*')
        .pipe(gulp.dest('dist'))
        .on('end', function(){ // after copying finishes…
            browserSync.reload() // … tell Browsersync to reload
        });
});

// build everything
gulp.task('build', ['css:compile', 'html:compile', 'static:copy']);

// development with automatic refreshing
gulp.task('develop', ['build'], function(){
    browserSync.init({ // initalize Browsersync
        // set what files be served
        server: {
            baseDir: 'dist', // serve from this folder
            serveStaticOptions: {
                // trying a extension when one isn't specified:
                // effectively means that http://localhost:3000/another-page shows another-page.html
                extensions: ['html']
            }
        }
    });
    gulp.watch('src/scss/**/*', ['css:compile']); // watch for changes in scss
    gulp.watch('src/templates/**/*', ['html:compile']); // watch for changes in templates
    gulp.watch('src/static/**/*', ['static:copy']); // watch for changes in static files
});

// set develop as a default task (gulp runs this when you don't specify a task)
gulp.task('default', ['develop']);
<|endoftext|>