<commit_before>/* jshint node: true */
/* jshint esversion: 6 */

'use strict';

/* =============================================================================
PLUGINS
============================================================================= */

const gulp = require('gulp'); // Gulp
const del = require('del'); // Borra archivos
const imagemin = require('gulp-imagemin'); // Optimizar imágenes
const uglify = require('gulp-uglify'); // Minificar JS
const concat = require('gulp-concat'); // Concatena ficheros
const plumber = require('gulp-plumber'); // Evita que gulp para de ejecutarse cuando tiene un error
const browser = require('browser-sync').create(); // Servidor local, refresco automático del navegador
const panini = require('panini'); // Simple html template engine generator
const prettify = require('gulp-jsbeautifier'); // Ordena el HTML final
const gulpif = require('gulp-if'); // Condicional if en pipes
const argv = require('yargs').argv; // Pasar variables por consola
const compression = require('compression'); // Gzip

// CSS
const sassToCSS = require('gulp-sass'); // Compilador de SASS
const sourcemaps = require('gulp-sourcemaps'); // Sourcemaps de SASS
const cssunit = require('gulp-css-unit'); // Convierte unidades
const postcss = require('gulp-postcss'); // Libreria necesaria para otros plugins
const autoprefixer = require('autoprefixer'); // Añade los prefijos necesarios a las propiedades CSS
const cssmqpacker = require('css-mqpacker'); // Junta las Mediaqueries y las mueve al final
const cssnano = require('cssnano'); // Minifica el CSS

/* =============================================================================
TASKS
============================================================================= */

gulp.task('build',
    gulp.series(clean, gulp.parallel(pages, scripts, images, copy, sass))
);

gulp.task('default',
    gulp.series('build', server, watch, function(done) {
        done();
    }
));

/* =============================================================================
FUNCTIONS
============================================================================= */

// Refresca el navegador
function reloadBrowser(done) {
    browser.reload();
    done();
}

// Elimina todo el contenido de dist y la documentacion de src
function clean() {
    return del('dist/**/*');
}

// Compila el HTML
function pages() {
    return gulp.src('src/html/pages/**/*.{html,hbs,handlebars}')
    .pipe(panini({
        root: 'src/html/pages/',
        layouts: 'src/html/layouts/',
        partials: 'src/html/partials/',
        helpers: 'src/html/helpers/',
        data: 'src/html/data/'
    })).pipe(prettify({
        max_preserve_newlines: 0
    }))
    .pipe(gulp.dest('dist/'));
}

// Carga las actualizaciones de los templates y los partials del HTML
function resetPages(done) {
    panini.refresh();
    done();
}

// Compila el Sass a CSS
function sass() {

    let pluginsPostcss = [
        autoprefixer({
            browsers: ['last 20 versions']
        }),
        cssmqpacker({
            sort: true
        })
    ];

    if (argv.production) {
        let pluginsPostcssProduction = [
            cssnano({
                discardUnused: {
                    fontFace: false
                }
            })
        ];

        pluginsPostcss = pluginsPostcss.concat(pluginsPostcssProduction);
    }

    return gulp.src([
        'src/assets/scss/main.scss'
    ])
    .pipe(gulpif(!argv.production, sourcemaps.init()))
    .pipe(sassToCSS()
    .on('error', sassToCSS.logError))
    .pipe(postcss(pluginsPostcss))
    .pipe(gulpif(!argv.production, sourcemaps.write('.', { sourceRoot: '/' })))
    .pipe(plumber())
    .pipe(gulp.dest('dist/assets/css/'))
    .pipe(browser.reload({ stream: true }));
}

// Concatena y minifica los Scripts
function scripts() {
    return gulp.src([
        'node_modules/jquery/dist/jquery.min.js',
        'src/assets/js/vendor/**/*.js',
        'src/assets/js/custom.js'
    ])
    .pipe(concat('main.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('dist/assets/js/'));
}

// Optimiza las imágenes y las mueve a dist
function images() {
    return gulp.src('src/assets/img/**/*')
    .pipe(gulpif(argv.production, imagemin({
        progressive: true
    })))
    .pipe(gulp.dest('dist/assets/img/'));
}

// Copia todos los assets a dist, menos los que empiezan por !
function copy() {
    return gulp.src([
        'src/assets/**/*.*',
        '!src/assets/{img,scss,js}{,/**}'
    ])
    .pipe(gulp.dest('dist/assets/'));
}

// Lanza el servidor con BrowserSync
function server(done) {
    browser.init({
        server: {
            baseDir: 'dist/',
            middleware: function(req, res, next) {
                if (argv.production) {
                    let gzip = compression();
                    gzip(req, res, next);
                } else {
                    next();
                }
            }
        }
    });
    done();
}

// Detecta los cambios en vivo y llama a las funciones
function watch(done) {
    gulp.watch('src/html/pages/**/*.{html,hbs,handlebars}').on('all', gulp.series(pages, reloadBrowser));
    gulp.watch('src/html/{layouts,partials}/**/*.{html,hbs,handlebars}').on('all', gulp.series(resetPages, pages, reloadBrowser));
    gulp.watch(['src/assets/scss/**/*.scss']).on('all', gulp.series(sass));
    gulp.watch('src/assets/img/**/*').on('all', gulp.series(images, reloadBrowser));
    gulp.watch([
        'src/assets/**/*',
        '!src/assets/{img,scss,js}{,/**}'
    ]).on('all', gulp.series(copy, reloadBrowser));
    gulp.watch('src/assets/js/**/*.js').on('all', gulp.series(scripts, reloadBrowser));
    done();
}<commit_msg>no message<commit_after>/* jshint node: true */
/* jshint esversion: 6 */

'use strict';

/* =============================================================================
PLUGINS
============================================================================= */

const gulp = require('gulp'); // Gulp
const del = require('del'); // Borra archivos
const imagemin = require('gulp-imagemin'); // Optimizar imágenes
const uglify = require('gulp-uglify'); // Minificar JS
const concat = require('gulp-concat'); // Concatena ficheros
const plumber = require('gulp-plumber'); // Evita que gulp para de ejecutarse cuando tiene un error
const browser = require('browser-sync').create(); // Servidor local, refresco automático del navegador
const panini = require('panini'); // Simple html template engine generator
const prettify = require('gulp-jsbeautifier'); // Ordena el HTML final
const gulpif = require('gulp-if'); // Condicional if en pipes
const argv = require('yargs').argv; // Pasar variables por consola
const compression = require('compression'); // Gzip

// CSS
const sassToCSS = require('gulp-sass'); // Compilador de SASS
const sourcemaps = require('gulp-sourcemaps'); // Sourcemaps de SASS
const cssunit = require('gulp-css-unit'); // Convierte unidades
const postcss = require('gulp-postcss'); // Libreria necesaria para otros plugins
const autoprefixer = require('autoprefixer'); // Añade los prefijos necesarios a las propiedades CSS
const cssmqpacker = require('css-mqpacker'); // Junta las Mediaqueries y las mueve al final
const cssnano = require('cssnano'); // Minifica el CSS

/* =============================================================================
TASKS
============================================================================= */

gulp.task('build',
    gulp.series(clean, gulp.parallel(pages, scripts, images, copy, sass))
);

gulp.task('default',
    gulp.series('build', server, watch, function(done) {
        done();
    }
));

/* =============================================================================
FUNCTIONS
============================================================================= */

// Refresca el navegador
function reloadBrowser(done) {
    browser.reload();
    done();
}

// Elimina todo el contenido de dist y la documentacion de src
function clean() {
    return del('dist/**/*');
}

// Compila el HTML
function pages() {
    return gulp.src('src/html/pages/**/*.{html,hbs,handlebars,php}')
    .pipe(panini({
        root: 'src/html/pages/',
        layouts: 'src/html/layouts/',
        partials: 'src/html/partials/',
        helpers: 'src/html/helpers/',
        data: 'src/html/data/'
    })).pipe(prettify({
        max_preserve_newlines: 0
    }))
    .pipe(gulp.dest('dist/'));
}

// Carga las actualizaciones de los templates y los partials del HTML
function resetPages(done) {
    panini.refresh();
    done();
}

// Compila el Sass a CSS
function sass() {

    let pluginsPostcss = [
        autoprefixer({
            browsers: ['last 20 versions']
        }),
        cssmqpacker({
            sort: true
        })
    ];

    if (argv.production) {
        let pluginsPostcssProduction = [
            cssnano({
                discardUnused: {
                    fontFace: false
                }
            })
        ];

        pluginsPostcss = pluginsPostcss.concat(pluginsPostcssProduction);
    }

    return gulp.src([
        'src/assets/scss/main.scss'
    ])
    .pipe(gulpif(!argv.production, sourcemaps.init()))
    .pipe(sassToCSS()
    .on('error', sassToCSS.logError))
    .pipe(postcss(pluginsPostcss))
    .pipe(gulpif(!argv.production, sourcemaps.write('.', { sourceRoot: '/' })))
    .pipe(plumber())
    .pipe(gulp.dest('dist/assets/css/'))
    .pipe(browser.reload({ stream: true }));
}

// Concatena y minifica los Scripts
function scripts() {
    return gulp.src([
        'node_modules/jquery/dist/jquery.min.js',
        'src/assets/js/vendor/**/*.js',
        'src/assets/js/custom.js'
    ])
    .pipe(concat('main.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('dist/assets/js/'));
}

// Optimiza las imágenes y las mueve a dist
function images() {
    return gulp.src('src/assets/img/**/*')
    .pipe(gulpif(argv.production, imagemin({
        progressive: true
    })))
    .pipe(gulp.dest('dist/assets/img/'));
}

// Copia todos los assets a dist, menos los que empiezan por !
function copy() {
    return gulp.src([
        'src/assets/**/*.*',
        '!src/assets/{img,scss,js}{,/**}'
    ])
    .pipe(gulp.dest('dist/assets/'));
}

// Lanza el servidor con BrowserSync
function server(done) {
    browser.init({
        server: {
            baseDir: 'dist/',
            middleware: function(req, res, next) {
                if (argv.production) {
                    let gzip = compression();
                    gzip(req, res, next);
                } else {
                    next();
                }
            }
        }
    });
    done();
}

// Detecta los cambios en vivo y llama a las funciones
function watch(done) {
    gulp.watch('src/html/pages/**/*.{html,hbs,handlebars,php}').on('all', gulp.series(pages, reloadBrowser));
    gulp.watch('src/html/{layouts,partials}/**/*.{html,hbs,handlebars}').on('all', gulp.series(resetPages, pages, reloadBrowser));
    gulp.watch(['src/assets/scss/**/*.scss']).on('all', gulp.series(sass));
    gulp.watch('src/assets/img/**/*').on('all', gulp.series(images, reloadBrowser));
    gulp.watch([
        'src/assets/**/*',
        '!src/assets/{img,scss,js}{,/**}'
    ]).on('all', gulp.series(copy, reloadBrowser));
    gulp.watch('src/assets/js/**/*.js').on('all', gulp.series(scripts, reloadBrowser));
    done();
}<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp');
// var gutil = require('gulp-util');
var sourcemaps = require('gulp-sourcemaps');
var transform = require('vinyl-transform');
var rename = require('gulp-rename');
var browserify = require('browserify');
var mocha = require('gulp-mocha');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var jshint = require('gulp-jshint');
// var uglify = require('gulp-uglify');
// var minifyCSS = require('gulp-minify-css');
var karma = require('karma');
var protractor = require('gulp-protractor').protractor;
var webdriver = require('gulp-protractor').webdriver;
// var webdriver_standalone = webdriver.webdriver_standalone;
var webdriverUpdate = require('gulp-protractor').webdriver_update;

var nodeFilesToWatch = ['app.js', 'api/**/*.js'];
var nodeTestFiles = ['api/**/test/*.js'];

/*
    Api tasks
*/
gulp.task('mocha', function () {
    return gulp.src(nodeTestFiles, {read: false})
        .pipe(mocha({reporter: 'spec'}));
});

gulp.task('lint-api', function() {
    return gulp.src(['app.js', './api/**/*.js'])
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

/*
    Client tasks
*/
gulp.task('browserify', function() {
    var bundle = transform(function(filename) {
        var b = browserify({
            entries: filename,
            debug: true,
            insertGlobals: true
        });
        return b.bundle();
    });

    return gulp.src(['./client/main.js'])
        .pipe(bundle)
        .pipe(sourcemaps.init({loadMaps: true}))
        // .pipe(uglify())
        .pipe(rename('bundle.js'))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./public'));
});

gulp.task('views', function () {
    gulp.src('client/index.html')
        .pipe(gulp.dest('public/'));

    gulp.src('client/todo/*.html')
        .pipe(gulp.dest('public/todo/'));
});

gulp.task('sass', function () {
    gulp.src('client/sass/*.scss')
        .pipe(sass({ onError: function (err) {
            console.error(err);
        }}))
        .pipe(autoprefixer('last 2 versions', '> 1%', 'ie 8'))
        .pipe(gulp.dest('public/css/'));
});

gulp.task('lint-client', function() {
    return gulp.src(['client/**/*.js', '!client/test/*.js'])
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

gulp.task('webdriver-update', webdriverUpdate);
gulp.task('webdriver', webdriver);

// gulp.task('webdriver_standalone', webdriver_standalone);

gulp.task('protractor', ['webdriver-update', 'webdriver'], function () {
    return gulp.src('client/**/test/*.e2e.js')
        .pipe(protractor({
            configFile: './protractor.conf.js',
            args: ['--baseUrl', 'http://127.0.0.1:3000']
        }))
        .on('error', function(err) {
            console.error(err);
        });
});

/*
    Watchers
*/
gulp.task('watch', function () {
    gulp.watch(['app.js', 'api/**/*.js'], ['lint-api']);
    gulp.watch(['client/**/*.js', '!client/test/*.js'], ['lint-client', 'browserify', 'protractor']);
    gulp.watch(['client/**/*.html'], ['views']);
    gulp.watch(['client/sass/*.scss'], ['sass']);
});

gulp.task('test', function () {
    gulp.watch(nodeFilesToWatch, ['mocha']);
    karma.server.start({
        configFile: __dirname + '/karma.conf.js'
    });
});
<commit_msg>combinded build and tests into one big task called dev<commit_after>'use strict';

var gulp = require('gulp');
// var gutil = require('gulp-util');
var sourcemaps = require('gulp-sourcemaps');
var transform = require('vinyl-transform');
var rename = require('gulp-rename');
var browserify = require('browserify');
var mocha = require('gulp-mocha');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var jshint = require('gulp-jshint');
// var uglify = require('gulp-uglify');
// var minifyCSS = require('gulp-minify-css');
var karma = require('karma');
var protractor = require('gulp-protractor').protractor;
var webdriver = require('gulp-protractor').webdriver;
// var webdriver_standalone = webdriver.webdriver_standalone;
var webdriverUpdate = require('gulp-protractor').webdriver_update;

var nodeFilesToWatch = ['app.js', 'api/**/*.js'];
var nodeTestFiles = ['api/**/test/*.js'];

/*
    Api tasks
*/
gulp.task('mocha', function () {
    return gulp.src(nodeTestFiles, {read: false})
        .pipe(mocha({reporter: 'spec'}));
});

gulp.task('lint-api', function() {
    return gulp.src(['app.js', './api/**/*.js'])
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

/*
    Client tasks
*/
gulp.task('browserify', function() {
    var bundle = transform(function(filename) {
        var b = browserify({
            entries: filename,
            debug: true,
            insertGlobals: true
        });
        return b.bundle();
    });

    return gulp.src(['./client/main.js'])
        .pipe(bundle)
        .pipe(sourcemaps.init({loadMaps: true}))
        // .pipe(uglify())
        .pipe(rename('bundle.js'))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./public'));
});

gulp.task('views', function () {
    gulp.src('client/index.html')
        .pipe(gulp.dest('public/'));

    gulp.src('client/todo/*.html')
        .pipe(gulp.dest('public/todo/'));
});

gulp.task('sass', function () {
    gulp.src('client/sass/*.scss')
        .pipe(sass({ onError: function (err) {
            console.error(err);
        }}))
        .pipe(autoprefixer('last 2 versions', '> 1%', 'ie 8'))
        .pipe(gulp.dest('public/css/'));
});

gulp.task('lint-client', function() {
    return gulp.src(['client/**/*.js', '!client/test/*.js'])
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

gulp.task('webdriver-update', webdriverUpdate);
gulp.task('webdriver', webdriver);

// gulp.task('webdriver_standalone', webdriver_standalone);

gulp.task('protractor', ['webdriver-update', 'webdriver'], function () {
    return gulp.src('client/**/test/*.e2e.js')
        .pipe(protractor({
            configFile: './protractor.conf.js',
            args: ['--baseUrl', 'http://127.0.0.1:3000']
        }))
        .on('error', function(err) {
            console.error(err);
        });
});

/*
    Watchers
*/
gulp.task('dev', function () {
    gulp.watch(['app.js', 'api/**/*.js'], ['lint-api']);
    gulp.watch(nodeFilesToWatch, ['mocha']);
    gulp.watch(['client/**/*.js', '!client/test/*.js'], ['lint-client', 'browserify', 'protractor']);
    gulp.watch(['client/**/*.html'], ['views']);
    gulp.watch(['client/sass/*.scss'], ['sass']);

    karma.server.start({
        configFile: __dirname + '/karma.conf.js'
    });
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var uglify = require('gulp-uglify');
var deleteFiles = require('del');
var sass = require('gulp-sass');
var filelog = require('gulp-filelog');
var include = require('gulp-include');
var jasmine = require('gulp-jasmine-phantom');
var sourcemaps = require('gulp-sourcemaps');

// Paths
var environment;
var repoRoot = __dirname + '/';
var bowerRoot = repoRoot + 'bower_components';
var npmRoot = repoRoot + 'node_modules';
var govukToolkitRoot = npmRoot + '/govuk_frontend_toolkit';
var dmToolkitRoot = bowerRoot + '/digitalmarketplace-frontend-toolkit/toolkit';
var sspContentRoot = bowerRoot + '/digitalmarketplace-frameworks';
var assetsFolder = repoRoot + 'app/assets';
var staticFolder = repoRoot + 'app/static';
var govukTemplateFolder = repoRoot + 'bower_components/govuk_template';
var govukTemplateAssetsFolder = govukTemplateFolder + '/assets';
var govukTemplateLayoutsFolder = govukTemplateFolder + '/views/layouts';

// JavaScript paths
var jsSourceFile = assetsFolder + '/javascripts/application.js';
var jsDistributionFolder = staticFolder + '/javascripts';
var jsDistributionFile = 'application.js';

// CSS paths
var cssSourceGlob = assetsFolder + '/scss/application*.scss';
var cssDistributionFolder = staticFolder + '/stylesheets';

// Configuration
var sassOptions = {
  development: {
    outputStyle: 'expanded',
    lineNumbers: true,
    includePaths: [
      assetsFolder + '/scss',
      dmToolkitRoot + '/scss',
      govukToolkitRoot + '/stylesheets',
    ],
    sourceComments: true,
    errLogToConsole: true
  },
  production: {
    outputStyle: 'compressed',
    lineNumbers: true,
    includePaths: [
      assetsFolder + '/scss',
      dmToolkitRoot + '/scss',
      govukToolkitRoot + '/stylesheets',
    ],
  },
};

var uglifyOptions = {
  development: {
    mangle: false,
    output: {
      beautify: true,
      semicolons: true,
      comments: true,
      indent_level: 2
    },
    compress: false
  },
  production: {
    mangle: true
  }
};

var logErrorAndExit = function logErrorAndExit(err) {

  // coloured text: https://coderwall.com/p/yphywg/printing-colorful-text-in-terminal-when-run-node-js-script
  console.log('\x1b[41m\x1b[37m  Error: ' + err.message + '\x1b[0m');
  process.exit(1);

};

gulp.task('clean', function (cb) {
  var fileTypes = [];
  var complete = function (fileType) {
    fileTypes.push(fileType);
    if (fileTypes.length == 2) {
      cb();
    }
  };
  var logOutputFor = function (fileType) {
    return function (err, paths) {
      if (paths !== undefined) {
        console.log('💥  Deleted the following ' + fileType + ' files:\n', paths.join('\n'));
      }
      complete(fileType);
    };
  };

  deleteFiles(jsDistributionFolder + '/**/*', logOutputFor('JavaScript'));
  deleteFiles(cssDistributionFolder + '/**/*', logOutputFor('CSS'));
});

gulp.task('sass', function () {
  var stream = gulp.src(cssSourceGlob)
    .pipe(filelog('Compressing SCSS files'))
    .pipe(
      sass(sassOptions[environment]))
        .on('error', logErrorAndExit)
    .pipe(gulp.dest(cssDistributionFolder));

  stream.on('end', function () {
    console.log('💾  Compressed CSS saved as .css files in ' + cssDistributionFolder);
  });

  return stream;
});

gulp.task('js', function () {
  var stream = gulp.src(jsSourceFile)
    .pipe(filelog('Compressing JavaScript files'))
    .pipe(include())
    .pipe(sourcemaps.init())
    .pipe(uglify(
      uglifyOptions[environment]
    ))
    .pipe(sourcemaps.write('./maps'))
    .pipe(gulp.dest(jsDistributionFolder));

  stream.on('end', function () {
    console.log('💾 Compressed JavaScript saved as ' + jsDistributionFolder + '/' + jsDistributionFile);
  });

  return stream;
});

function copyFactory(resourceName, sourceFolder, targetFolder) {

  return function() {

    return gulp
      .src(sourceFolder + "/**/*", { base: sourceFolder })
      .pipe(gulp.dest(targetFolder))
      .on('end', function () {
        console.log('📂  Copied ' + resourceName);
      });

  };

}

gulp.task(
  'copy:template_assets:stylesheets',
  copyFactory(
    "GOV.UK template stylesheets",
    govukTemplateAssetsFolder + '/stylesheets',
    staticFolder + '/stylesheets'
  )
);

gulp.task(
  'copy:template_assets:images',
  copyFactory(
    "GOV.UK template images",
    govukTemplateAssetsFolder + '/images',
    staticFolder + '/images'
  )
);

gulp.task(
  'copy:template_assets:javascripts',
  copyFactory(
    'GOV.UK template Javascript files',
    govukTemplateAssetsFolder + '/javascripts',
    staticFolder + '/javascripts'
  )
);

gulp.task(
  'copy:dm_toolkit_assets:stylesheets',
  copyFactory(
    "stylesheets from the Digital Marketplace frontend toolkit",
    dmToolkitRoot + '/scss',
    'app/assets/scss/toolkit'
  )
);

gulp.task(
  'copy:dm_toolkit_assets:images',
  copyFactory(
    "images from the Digital Marketplace frontend toolkit",
    dmToolkitRoot + '/images',
    staticFolder + '/images'
  )
);

gulp.task(
  'copy:govuk_toolkit_assets:images',
  copyFactory(
    "images from the GOVUK frontend toolkit",
    govukToolkitRoot + '/images',
    staticFolder + '/images'
  )
);

gulp.task(
  'copy:dm_toolkit_assets:templates',
  copyFactory(
    "templates from the Digital Marketplace frontend toolkit",
    dmToolkitRoot + '/templates',
    'app/templates/toolkit'
  )
);

gulp.task(
  'copy:images',
  copyFactory(
    "image assets from app to static folder",
    assetsFolder + '/images',
    staticFolder + '/images'
  )
);

gulp.task(
  'copy:svg',
  copyFactory(
    "image assets from app to static folder",
    assetsFolder + '/svg',
    staticFolder + '/svg'
  )
);

gulp.task(
  'copy:govuk_template',
  copyFactory(
    "GOV.UK template into app folder",
    govukTemplateLayoutsFolder,
    'app/templates/govuk'
  )
);

gulp.task(
  'copy:ssp_content',
  copyFactory(
    "content YAML into app folder",
    sspContentRoot, 'app/content'
  )
);

gulp.task('test', function () {
  var manifest = require(repoRoot + 'spec/javascripts/manifest.js').manifest;

  manifest.support = manifest.support.map(function (val) {
    return val.replace(/^(\.\.\/){3}/, '');
  });
  manifest.test = manifest.test.map(function (val) {
    return val.replace(/^\.\.\//, 'spec/javascripts/');
  });

  return gulp.src(manifest.test)
    .pipe(jasmine({
      'jasmine': '2.0',
      'integration': true,
      'abortOnFail': true,
      'vendor': manifest.support
    }));
});

gulp.task('watch', ['build:development'], function () {
  var jsWatcher = gulp.watch([ assetsFolder + '/**/*.js' ], ['js']);
  var cssWatcher = gulp.watch([ assetsFolder + '/**/*.scss' ], ['sass']);
  var notice = function (event) {
    console.log('File ' + event.path + ' was ' + event.type + ' running tasks...');
  };

  cssWatcher.on('change', notice);
  jsWatcher.on('change', notice);
});

gulp.task('set_environment_to_development', function (cb) {
  environment = 'development';
  cb();
});

gulp.task('set_environment_to_production', function (cb) {
  environment = 'production';
  cb();
});

gulp.task(
  'copy',
  [
    'copy:ssp_content',
    'copy:template_assets:images',
    'copy:template_assets:stylesheets',
    'copy:template_assets:javascripts',
    'copy:govuk_toolkit_assets:images',
    'copy:dm_toolkit_assets:stylesheets',
    'copy:dm_toolkit_assets:images',
    'copy:dm_toolkit_assets:templates',
    'copy:images',
    'copy:svg',
    'copy:govuk_template'
  ]
);

gulp.task(
  'compile',
  [
    'copy'
  ],
  function() {
    gulp.start('sass');
    gulp.start('js');
  }
);

gulp.task('build:development', ['set_environment_to_development', 'clean'], function () {
  gulp.start('compile');
});

gulp.task('build:production', ['set_environment_to_production', 'clean'], function () {
  gulp.start('compile');
});
<commit_msg>Add new watcher for frameworks to make framework dev nicer  - vaguely related to [#134252361]  - bower now copies only the frameworks YAML directory, not the entire frameworks    repo, for consistency with the admin frontend<commit_after>var gulp = require('gulp');
var uglify = require('gulp-uglify');
var deleteFiles = require('del');
var sass = require('gulp-sass');
var filelog = require('gulp-filelog');
var include = require('gulp-include');
var jasmine = require('gulp-jasmine-phantom');
var sourcemaps = require('gulp-sourcemaps');

// Paths
var environment;
var repoRoot = __dirname + '/';
var bowerRoot = repoRoot + 'bower_components';
var npmRoot = repoRoot + 'node_modules';
var govukToolkitRoot = npmRoot + '/govuk_frontend_toolkit';
var dmToolkitRoot = bowerRoot + '/digitalmarketplace-frontend-toolkit/toolkit';
var sspContentRoot = bowerRoot + '/digitalmarketplace-frameworks';
var assetsFolder = repoRoot + 'app/assets';
var staticFolder = repoRoot + 'app/static';
var govukTemplateFolder = repoRoot + 'bower_components/govuk_template';
var govukTemplateAssetsFolder = govukTemplateFolder + '/assets';
var govukTemplateLayoutsFolder = govukTemplateFolder + '/views/layouts';

// JavaScript paths
var jsSourceFile = assetsFolder + '/javascripts/application.js';
var jsDistributionFolder = staticFolder + '/javascripts';
var jsDistributionFile = 'application.js';

// CSS paths
var cssSourceGlob = assetsFolder + '/scss/application*.scss';
var cssDistributionFolder = staticFolder + '/stylesheets';

// Configuration
var sassOptions = {
  development: {
    outputStyle: 'expanded',
    lineNumbers: true,
    includePaths: [
      assetsFolder + '/scss',
      dmToolkitRoot + '/scss',
      govukToolkitRoot + '/stylesheets',
    ],
    sourceComments: true,
    errLogToConsole: true
  },
  production: {
    outputStyle: 'compressed',
    lineNumbers: true,
    includePaths: [
      assetsFolder + '/scss',
      dmToolkitRoot + '/scss',
      govukToolkitRoot + '/stylesheets',
    ],
  },
};

var uglifyOptions = {
  development: {
    mangle: false,
    output: {
      beautify: true,
      semicolons: true,
      comments: true,
      indent_level: 2
    },
    compress: false
  },
  production: {
    mangle: true
  }
};

var logErrorAndExit = function logErrorAndExit(err) {

  // coloured text: https://coderwall.com/p/yphywg/printing-colorful-text-in-terminal-when-run-node-js-script
  console.log('\x1b[41m\x1b[37m  Error: ' + err.message + '\x1b[0m');
  process.exit(1);

};

gulp.task('clean', function (cb) {
  var fileTypes = [];
  var complete = function (fileType) {
    fileTypes.push(fileType);
    if (fileTypes.length == 2) {
      cb();
    }
  };
  var logOutputFor = function (fileType) {
    return function (err, paths) {
      if (paths !== undefined) {
        console.log('💥  Deleted the following ' + fileType + ' files:\n', paths.join('\n'));
      }
      complete(fileType);
    };
  };

  deleteFiles(jsDistributionFolder + '/**/*', logOutputFor('JavaScript'));
  deleteFiles(cssDistributionFolder + '/**/*', logOutputFor('CSS'));
});

gulp.task('sass', function () {
  var stream = gulp.src(cssSourceGlob)
    .pipe(filelog('Compressing SCSS files'))
    .pipe(
      sass(sassOptions[environment]))
        .on('error', logErrorAndExit)
    .pipe(gulp.dest(cssDistributionFolder));

  stream.on('end', function () {
    console.log('💾  Compressed CSS saved as .css files in ' + cssDistributionFolder);
  });

  return stream;
});

gulp.task('js', function () {
  var stream = gulp.src(jsSourceFile)
    .pipe(filelog('Compressing JavaScript files'))
    .pipe(include())
    .pipe(sourcemaps.init())
    .pipe(uglify(
      uglifyOptions[environment]
    ))
    .pipe(sourcemaps.write('./maps'))
    .pipe(gulp.dest(jsDistributionFolder));

  stream.on('end', function () {
    console.log('💾 Compressed JavaScript saved as ' + jsDistributionFolder + '/' + jsDistributionFile);
  });

  return stream;
});

function copyFactory(resourceName, sourceFolder, targetFolder) {

  return function() {

    return gulp
      .src(sourceFolder + "/**/*", { base: sourceFolder })
      .pipe(gulp.dest(targetFolder))
      .on('end', function () {
        console.log('📂  Copied ' + resourceName);
      });

  };

}

gulp.task(
  'copy:template_assets:stylesheets',
  copyFactory(
    "GOV.UK template stylesheets",
    govukTemplateAssetsFolder + '/stylesheets',
    staticFolder + '/stylesheets'
  )
);

gulp.task(
  'copy:template_assets:images',
  copyFactory(
    "GOV.UK template images",
    govukTemplateAssetsFolder + '/images',
    staticFolder + '/images'
  )
);

gulp.task(
  'copy:template_assets:javascripts',
  copyFactory(
    'GOV.UK template Javascript files',
    govukTemplateAssetsFolder + '/javascripts',
    staticFolder + '/javascripts'
  )
);

gulp.task(
  'copy:dm_toolkit_assets:stylesheets',
  copyFactory(
    "stylesheets from the Digital Marketplace frontend toolkit",
    dmToolkitRoot + '/scss',
    'app/assets/scss/toolkit'
  )
);

gulp.task(
  'copy:dm_toolkit_assets:images',
  copyFactory(
    "images from the Digital Marketplace frontend toolkit",
    dmToolkitRoot + '/images',
    staticFolder + '/images'
  )
);

gulp.task(
  'copy:govuk_toolkit_assets:images',
  copyFactory(
    "images from the GOVUK frontend toolkit",
    govukToolkitRoot + '/images',
    staticFolder + '/images'
  )
);

gulp.task(
  'copy:dm_toolkit_assets:templates',
  copyFactory(
    "templates from the Digital Marketplace frontend toolkit",
    dmToolkitRoot + '/templates',
    'app/templates/toolkit'
  )
);

gulp.task(
  'copy:images',
  copyFactory(
    "image assets from app to static folder",
    assetsFolder + '/images',
    staticFolder + '/images'
  )
);

gulp.task(
  'copy:svg',
  copyFactory(
    "image assets from app to static folder",
    assetsFolder + '/svg',
    staticFolder + '/svg'
  )
);

gulp.task(
  'copy:govuk_template',
  copyFactory(
    "GOV.UK template into app folder",
    govukTemplateLayoutsFolder,
    'app/templates/govuk'
  )
);

gulp.task(
  'copy:frameworks',
  copyFactory(
    "frameworks YAML into app folder",
    sspContentRoot + '/frameworks', 'app/content/frameworks'
  )
);

gulp.task('test', function () {
  var manifest = require(repoRoot + 'spec/javascripts/manifest.js').manifest;

  manifest.support = manifest.support.map(function (val) {
    return val.replace(/^(\.\.\/){3}/, '');
  });
  manifest.test = manifest.test.map(function (val) {
    return val.replace(/^\.\.\//, 'spec/javascripts/');
  });

  return gulp.src(manifest.test)
    .pipe(jasmine({
      'jasmine': '2.0',
      'integration': true,
      'abortOnFail': true,
      'vendor': manifest.support
    }));
});

gulp.task('watch', ['build:development'], function () {
  var jsWatcher = gulp.watch([ assetsFolder + '/**/*.js' ], ['js']);
  var cssWatcher = gulp.watch([ assetsFolder + '/**/*.scss' ], ['sass']);
  var dmWatcher = gulp.watch([ bowerRoot + '/digitalmarketplace-frameworks/**' ], ['copy:frameworks']);
  var notice = function (event) {
    console.log('File ' + event.path + ' was ' + event.type + ' running tasks...');
  };

  cssWatcher.on('change', notice);
  jsWatcher.on('change', notice);
});

gulp.task('set_environment_to_development', function (cb) {
  environment = 'development';
  cb();
});

gulp.task('set_environment_to_production', function (cb) {
  environment = 'production';
  cb();
});

gulp.task(
  'copy',
  [
    'copy:frameworks',
    'copy:template_assets:images',
    'copy:template_assets:stylesheets',
    'copy:template_assets:javascripts',
    'copy:govuk_toolkit_assets:images',
    'copy:dm_toolkit_assets:stylesheets',
    'copy:dm_toolkit_assets:images',
    'copy:dm_toolkit_assets:templates',
    'copy:images',
    'copy:svg',
    'copy:govuk_template'
  ]
);

gulp.task(
  'compile',
  [
    'copy'
  ],
  function() {
    gulp.start('sass');
    gulp.start('js');
  }
);

gulp.task('build:development', ['set_environment_to_development', 'clean'], function () {
  gulp.start('compile');
});

gulp.task('build:production', ['set_environment_to_production', 'clean'], function () {
  gulp.start('compile');
});
<|endoftext|>


<commit_before>/*
 * require gulp plugins
 */
var gulp         = require('gulp'),
    plumber      = require('gulp-plumber'),
    sass         = require('gulp-sass'),
    autoprefixer = require('gulp-autoprefixer'),
    minifycss    = require('gulp-minify-css'),
    newer        = require('gulp-newer'),
    imagemin     = require('gulp-imagemin'),
    livereload   = require('gulp-livereload'),
    lr           = require('tiny-lr'),
    server       = lr();

/*
 * common directories
 */
var src         = 'wp-content/themes/theopenpress/src',
    images      = src + '/images',
    stylesheets = src + '/stylesheets',
    scripts     = src + '/scripts',
    build       = 'wp-content/themes/theopenpress/assets',
    img         = build + '/img',
    css         = build + '/css',
    js          = build + '/js';

/*
 * styles task
 */
gulp.task('styles', function() {
  return gulp.src(stylesheets + '/app.scss', {base: stylesheets})
/*   return gulp.src(stylesheets + '/app.scss', {base: stylesheets}) */
    .pipe(plumber())
    .pipe(sass({style: 'expanded'}))
    .pipe(gulp.dest(css))
    .pipe(autoprefixer('last 2 versions'))
    .pipe(minifycss())
    .pipe(gulp.dest(css))
    .pipe(livereload(server));
});

/*
 * images task
 */
gulp.task('images', function() {
  return gulp.src(images + '/*', {base: images})
    .pipe(newer(img))
    .pipe(imagemin({optimizationLevel: 3, progressive: true, interlaced: true}))
    .pipe(gulp.dest(img));
});

/*
 * watch task
 */
gulp.task('watch', function() {
  server.listen(35739, function(error) {
    if (error) {
      return console.log(error)
    };
    gulp.watch(stylesheets + '/*.scss', ['styles']);
    gulp.watch(stylesheets + '/**/*.scss', ['styles']);
    gulp.watch(images + '/**', ['images']);
  });
});

/*
 * default task
 */
gulp.task('default', ['styles', 'images', 'watch']);
<commit_msg>Remove duplicate commented gulp task line<commit_after>/*
 * require gulp plugins
 */
var gulp         = require('gulp'),
    plumber      = require('gulp-plumber'),
    sass         = require('gulp-sass'),
    autoprefixer = require('gulp-autoprefixer'),
    minifycss    = require('gulp-minify-css'),
    newer        = require('gulp-newer'),
    imagemin     = require('gulp-imagemin'),
    livereload   = require('gulp-livereload'),
    lr           = require('tiny-lr'),
    server       = lr();

/*
 * common directories
 */
var src         = 'wp-content/themes/theopenpress/src',
    images      = src + '/images',
    stylesheets = src + '/stylesheets',
    scripts     = src + '/scripts',
    build       = 'wp-content/themes/theopenpress/assets',
    img         = build + '/img',
    css         = build + '/css',
    js          = build + '/js';

/*
 * styles task
 */
gulp.task('styles', function() {
  return gulp.src(stylesheets + '/app.scss', {base: stylesheets})
    .pipe(plumber())
    .pipe(sass({style: 'expanded'}))
    .pipe(gulp.dest(css))
    .pipe(autoprefixer('last 2 versions'))
    .pipe(minifycss())
    .pipe(gulp.dest(css))
    .pipe(livereload(server));
});

/*
 * images task
 */
gulp.task('images', function() {
  return gulp.src(images + '/*', {base: images})
    .pipe(newer(img))
    .pipe(imagemin({optimizationLevel: 3, progressive: true, interlaced: true}))
    .pipe(gulp.dest(img));
});

/*
 * watch task
 */
gulp.task('watch', function() {
  server.listen(35739, function(error) {
    if (error) {
      return console.log(error)
    };
    gulp.watch(stylesheets + '/*.scss', ['styles']);
    gulp.watch(stylesheets + '/**/*.scss', ['styles']);
    gulp.watch(images + '/**', ['images']);
  });
});

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


<commit_before>// Load Gulp and all of our Gulp plugins
const gulp = require('gulp');
const $ = require('gulp-load-plugins')();

// Load other npm modules
const del = require('del');
const glob = require('glob');
const path = require('path');
const isparta = require('isparta');
const babelify = require('babelify');
const watchify = require('watchify');
const buffer = require('vinyl-buffer');
const esperanto = require('esperanto');
const browserify = require('browserify');
const runSequence = require('run-sequence');
const source = require('vinyl-source-stream');

// Gather the library data from `package.json`
const manifest = require('./package.json');
const config = manifest.babelBoilerplateOptions;
const mainFile = manifest.main;
const destinationFolder = path.dirname(mainFile);
const exportFileName = path.basename(mainFile, path.extname(mainFile));

// Remove the built files
gulp.task('clean', function(cb) {
  del([destinationFolder], cb);
});

// Remove our temporary files
gulp.task('clean-tmp', function(cb) {
  del(['tmp'], cb);
});

// Send a notification when JSCS fails,
// so that you know your changes didn't build
function jscsNotify(file) {
  if (!file.jscs) { return; }
  return file.jscs.success ? false : 'JSCS failed';
}

function createLintTask(taskName, files) {
  gulp.task(taskName, function() {
    return gulp.src(files)
      .pipe($.plumber())
      .pipe($.eslint())
      .pipe($.eslint.format())
      .pipe($.eslint.failOnError())
      .pipe($.jscs())
      .pipe($.notify(jscsNotify));
  });
}

// Lint our source code
createLintTask('lint-src', ['src/**/*.js']);

// Lint our test code
createLintTask('lint-test', ['test/**/*.js']);

// Build two versions of the library
gulp.task('build', ['lint-src', 'clean', 'stylus'], function(done) {
  esperanto.bundle({
    base: 'src',
    entry: config.entryFileName,
  }).then(function(bundle) {
    var res = bundle.toUmd({
      // Don't worry about the fact that the source map is inlined at this step.
      // `gulp-sourcemaps`, which comes next, will externalize them.
      sourceMap: 'inline',
      name: config.mainVarName
    });

    $.file(exportFileName + '.js', res.code, { src: true })
      .pipe($.plumber())
      .pipe($.sourcemaps.init({ loadMaps: true }))
      .pipe($.babel())
      .pipe($.sourcemaps.write('./'))
      .pipe(gulp.dest(destinationFolder))
      .pipe($.filter(['*', '!**/*.js.map']))
      .pipe($.rename(exportFileName + '.min.js'))
      .pipe($.sourcemaps.init({ loadMaps: true }))
      .pipe($.uglify())
      .pipe($.sourcemaps.write('./'))
      .pipe(gulp.dest(destinationFolder))
      .on('end', done);
  })
  .catch(done);
});

function bundle(bundler) {
  return bundler.bundle()
    .on('error', function(err) {
      console.log(err.message);
      this.emit('end');
    })
    .pipe($.plumber())
    .pipe(source('./tmp/__spec-build.js'))
    .pipe(buffer())
    .pipe(gulp.dest(''))
    .pipe($.livereload());
}

function getBundler() {
  // Our browserify bundle is made up of our unit tests, which
  // should individually load up pieces of our application.
  // We also include the browserify setup file.
  var testFiles = glob.sync('./test/unit/**/*');
  var allFiles = ['./test/setup/browserify.js'].concat(testFiles);

  // Create our bundler, passing in the arguments required for watchify
  var bundler = browserify(allFiles, watchify.args);

  // Watch the bundler, and re-bundle it whenever files change
  bundler = watchify(bundler);
  bundler.on('update', function() {
    bundle(bundler);
  });

  // Set up Babelify so that ES6 works in the tests
  bundler.transform(babelify.configure({
    sourceMapRelative: __dirname + '/src'
  }));

  return bundler;
};

// Build the unit test suite for running tests
// in the browser
gulp.task('browserify', function() {
  return bundle(getBundler());
});

function test() {
  return gulp.src(['test/setup/node.js', 'test/unit/**/*.js'], {read: false})
    .pipe($.mocha({reporter: 'dot', globals: config.mochaGlobals}));
}

gulp.task('coverage', ['lint-src', 'lint-test'], function(done) {
  require('babel-core/register');
  gulp.src(['src/**/*.js'])
    .pipe($.istanbul({ instrumenter: isparta.Instrumenter }))
    .pipe($.istanbul.hookRequire())
    .on('finish', function() {
      return test()
        .pipe($.istanbul.writeReports())
        .on('end', done);
    });
});

// Lint and run our tests
gulp.task('test', ['lint-src', 'lint-test'], function() {
  require('babel-core/register');
  return test();
});

gulp.task('stylus', function() {
  return gulp.src('./src/marionette.overlay-view.styl')
    .pipe($.stylus({
      compress:true
    }))
    .pipe(gulp.dest('./dest'));
});

// Ensure that linting occurs before browserify runs. This prevents
// the build from breaking due to poorly formatted code.
gulp.task('build-in-sequence', function(callback) {
  runSequence(['lint-src', 'lint-test'], 'browserify', callback);
});

// These are JS files that should be watched by Gulp. When running tests in the browser,
// watchify is used instead, so these aren't included.
const jsWatchFiles = ['src/**/*', 'test/**/*'];
// These are files other than JS files which are to be watched. They are always watched.
const otherWatchFiles = ['package.json', '**/.eslintrc', '.jscsrc'];

// Run the headless unit tests as you make changes.
gulp.task('watch', function() {
  const watchFiles = jsWatchFiles.concat(otherWatchFiles);
  gulp.watch(watchFiles, ['test']);
});

// Set up a livereload environment for our spec runner
gulp.task('test-browser', ['build-in-sequence'], function() {
  $.livereload.listen({port: 35729, host: 'localhost', start: true});
  return gulp.watch(otherWatchFiles, ['build-in-sequence']);
});

// An alias of test
gulp.task('default', ['test']);
<commit_msg>Update stylus build destination.<commit_after>// Load Gulp and all of our Gulp plugins
const gulp = require('gulp');
const $ = require('gulp-load-plugins')();

// Load other npm modules
const del = require('del');
const glob = require('glob');
const path = require('path');
const isparta = require('isparta');
const babelify = require('babelify');
const watchify = require('watchify');
const buffer = require('vinyl-buffer');
const esperanto = require('esperanto');
const browserify = require('browserify');
const runSequence = require('run-sequence');
const source = require('vinyl-source-stream');

// Gather the library data from `package.json`
const manifest = require('./package.json');
const config = manifest.babelBoilerplateOptions;
const mainFile = manifest.main;
const destinationFolder = path.dirname(mainFile);
const exportFileName = path.basename(mainFile, path.extname(mainFile));

// Remove the built files
gulp.task('clean', function(cb) {
  del([destinationFolder], cb);
});

// Remove our temporary files
gulp.task('clean-tmp', function(cb) {
  del(['tmp'], cb);
});

// Send a notification when JSCS fails,
// so that you know your changes didn't build
function jscsNotify(file) {
  if (!file.jscs) { return; }
  return file.jscs.success ? false : 'JSCS failed';
}

function createLintTask(taskName, files) {
  gulp.task(taskName, function() {
    return gulp.src(files)
      .pipe($.plumber())
      .pipe($.eslint())
      .pipe($.eslint.format())
      .pipe($.eslint.failOnError())
      .pipe($.jscs())
      .pipe($.notify(jscsNotify));
  });
}

// Lint our source code
createLintTask('lint-src', ['src/**/*.js']);

// Lint our test code
createLintTask('lint-test', ['test/**/*.js']);

// Build two versions of the library
gulp.task('build', ['lint-src', 'clean', 'stylus'], function(done) {
  esperanto.bundle({
    base: 'src',
    entry: config.entryFileName,
  }).then(function(bundle) {
    var res = bundle.toUmd({
      // Don't worry about the fact that the source map is inlined at this step.
      // `gulp-sourcemaps`, which comes next, will externalize them.
      sourceMap: 'inline',
      name: config.mainVarName
    });

    $.file(exportFileName + '.js', res.code, { src: true })
      .pipe($.plumber())
      .pipe($.sourcemaps.init({ loadMaps: true }))
      .pipe($.babel())
      .pipe($.sourcemaps.write('./'))
      .pipe(gulp.dest(destinationFolder))
      .pipe($.filter(['*', '!**/*.js.map']))
      .pipe($.rename(exportFileName + '.min.js'))
      .pipe($.sourcemaps.init({ loadMaps: true }))
      .pipe($.uglify())
      .pipe($.sourcemaps.write('./'))
      .pipe(gulp.dest(destinationFolder))
      .on('end', done);
  })
  .catch(done);
});

function bundle(bundler) {
  return bundler.bundle()
    .on('error', function(err) {
      console.log(err.message);
      this.emit('end');
    })
    .pipe($.plumber())
    .pipe(source('./tmp/__spec-build.js'))
    .pipe(buffer())
    .pipe(gulp.dest(''))
    .pipe($.livereload());
}

function getBundler() {
  // Our browserify bundle is made up of our unit tests, which
  // should individually load up pieces of our application.
  // We also include the browserify setup file.
  var testFiles = glob.sync('./test/unit/**/*');
  var allFiles = ['./test/setup/browserify.js'].concat(testFiles);

  // Create our bundler, passing in the arguments required for watchify
  var bundler = browserify(allFiles, watchify.args);

  // Watch the bundler, and re-bundle it whenever files change
  bundler = watchify(bundler);
  bundler.on('update', function() {
    bundle(bundler);
  });

  // Set up Babelify so that ES6 works in the tests
  bundler.transform(babelify.configure({
    sourceMapRelative: __dirname + '/src'
  }));

  return bundler;
};

// Build the unit test suite for running tests
// in the browser
gulp.task('browserify', function() {
  return bundle(getBundler());
});

function test() {
  return gulp.src(['test/setup/node.js', 'test/unit/**/*.js'], {read: false})
    .pipe($.mocha({reporter: 'dot', globals: config.mochaGlobals}));
}

gulp.task('coverage', ['lint-src', 'lint-test'], function(done) {
  require('babel-core/register');
  gulp.src(['src/**/*.js'])
    .pipe($.istanbul({ instrumenter: isparta.Instrumenter }))
    .pipe($.istanbul.hookRequire())
    .on('finish', function() {
      return test()
        .pipe($.istanbul.writeReports())
        .on('end', done);
    });
});

// Lint and run our tests
gulp.task('test', ['lint-src', 'lint-test'], function() {
  require('babel-core/register');
  return test();
});

gulp.task('stylus', function() {
  return gulp.src('./src/marionette.overlay-view.styl')
    .pipe($.stylus({
      compress:true
    }))
    .pipe(gulp.dest('./dist'));
});

// Ensure that linting occurs before browserify runs. This prevents
// the build from breaking due to poorly formatted code.
gulp.task('build-in-sequence', function(callback) {
  runSequence(['lint-src', 'lint-test'], 'browserify', callback);
});

// These are JS files that should be watched by Gulp. When running tests in the browser,
// watchify is used instead, so these aren't included.
const jsWatchFiles = ['src/**/*', 'test/**/*'];
// These are files other than JS files which are to be watched. They are always watched.
const otherWatchFiles = ['package.json', '**/.eslintrc', '.jscsrc'];

// Run the headless unit tests as you make changes.
gulp.task('watch', function() {
  const watchFiles = jsWatchFiles.concat(otherWatchFiles);
  gulp.watch(watchFiles, ['test']);
});

// Set up a livereload environment for our spec runner
gulp.task('test-browser', ['build-in-sequence'], function() {
  $.livereload.listen({port: 35729, host: 'localhost', start: true});
  return gulp.watch(otherWatchFiles, ['build-in-sequence']);
});

// An alias of test
gulp.task('default', ['test']);
<|endoftext|>


<commit_before>"use strict";

/**
 * Gulp usage file for the whole project.
 */

var gulp = require("gulp");
var ts = require("gulp-typescript");
var eventStream = require("event-stream");
var tslint = require("gulp-tslint");
var sequence = require("run-sequence").use(gulp);
var babel = require("gulp-babel");
var path = require("path");

var typeScriptSource = [
    "./typedefinitions/backend.d.ts",
    "./backend/**/*.ts"
];
var typeScriptDestination = "./release/";

// TYPESCRIPT COMPILATION
gulp.task("typescript", function() {
    return gulp
        .src( typeScriptSource )
        // Pipe source to lint
        .pipe(tslint())
        .pipe(tslint.report("verbose"))
        // Push through to compiler
        .pipe(ts({
            typescript: require("typescript"),
            declarationFiles: false,
            noImplicitAny: true,
            noExternalResolve: false,
            removeComments: true,
            target: "es6",
            showErrors: true
        }))
        // Through babel (es6->es5)
        .pipe(babel({
            comments: false,
            presets: [ "es2015" ]
        }))
        .pipe(gulp.dest(typeScriptDestination));

});

/**
 * Run with: 'gulp w'
 */
gulp.task("w", function() {
    gulp.watch(typeScriptSource, [ "typescript" ]);
});
<commit_msg>Add default gulp compilation.<commit_after>"use strict";

/**
 * Gulp usage file for the whole project.
 */

var gulp = require("gulp");
var ts = require("gulp-typescript");
var eventStream = require("event-stream");
var tslint = require("gulp-tslint");
var sequence = require("run-sequence").use(gulp);
var babel = require("gulp-babel");
var path = require("path");

var typeScriptSource = [
    "./typedefinitions/backend.d.ts",
    "./backend/**/*.ts"
];
var typeScriptDestination = "./release/";

// TYPESCRIPT COMPILATION
gulp.task("typescript", function() {
    return gulp
        .src( typeScriptSource )
        // Pipe source to lint
        .pipe(tslint())
        .pipe(tslint.report("verbose"))
        // Push through to compiler
        .pipe(ts({
            typescript: require("typescript"),
            declarationFiles: false,
            noImplicitAny: true,
            noExternalResolve: false,
            removeComments: true,
            target: "es6",
            showErrors: true
        }))
        // Through babel (es6->es5)
        .pipe(babel({
            comments: false,
            presets: [ "es2015" ]
        }))
        .pipe(gulp.dest(typeScriptDestination));

});

/**
 * Run with: 'gulp w'
 */
gulp.task("w", function() {
    gulp.watch(typeScriptSource, [ "typescript" ]);
});

/**
 * Run with: 'gulp' or 'gulp default'
 */
gulp.task("default", function() {
    return sequence([ "typescript" ]);
});
<|endoftext|>


<commit_before>var gulp=require('gulp');
var reload=require('require-reload')(require);
var notify=require('gulp-notify');
var file=require('gulp-file');
var browserify=require('browserify');
var source=require('vinyl-source-stream');
var buffer=require('vinyl-buffer');
var sourcemaps=require('gulp-sourcemaps');
var wrapJS=require('gulp-wrap-js');
var uglify=require('gulp-uglify');
var less=require('gulp-less');
var autoprefixer=require('gulp-autoprefixer');
var minifyCss=require('gulp-minify-css');
var mocha=require('gulp-mocha');

var demoDestination='public_html/en/base';
var libDestination='public_html/lib';

// https://github.com/greypants/gulp-starter/blob/master/gulp/util/handleErrors.js
function handleErrors() {
	var args=Array.prototype.slice.call(arguments);
	notify.onError({
		title: "Compile Error",
		message: "<%= error %>"
	}).apply(this,args);
	this.emit('end');
}

gulp.task('html',function(){
	return file(
		'index.html',
		reload('./demos/template.js')(
			"WebGL starter code generator",
			['http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.7/styles/default.min.css'],
			['http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.7/highlight.min.js']
		),
		{src: true}
	)
		.pipe(gulp.dest(demoDestination));
});

gulp.task('css',function(){
	gulp.src('src/webgl-starter.less')
		.pipe(sourcemaps.init())
		.pipe(less())
		.on('error',handleErrors)
		.pipe(autoprefixer())
		.pipe(minifyCss())
		.pipe(sourcemaps.write('.',{
			sourceRoot: '.'
		}))
		.pipe(gulp.dest(libDestination));
});

gulp.task('js',function(){
	browserify({
		entries: 'src/main.js',
		debug: true
	})
		.transform('babelify',{
			presets:['es2015-loose'],
			plugins:['external-helpers-2'],
		})
		.bundle()
		.on('error',handleErrors)
		.pipe(source('webgl-starter.js'))
		.pipe(buffer())
		.pipe(sourcemaps.init({
			loadMaps: true
		}))
		.pipe(wrapJS(
			reload('./src/base/babel-helpers-wrapper.js')()
		))
		.pipe(uglify())
		.pipe(sourcemaps.write('.',{
			sourceRoot: '.'
		}))
		.pipe(gulp.dest(libDestination));
});

gulp.task('watch',function(){
	gulp.watch(['demos/*'],['html']);
	gulp.watch(['src/**/*.js'],['js']);
	gulp.watch(['src/index.less'],['css']);
});

gulp.task('test',function(){
	gulp.src('tests/**/*.js')
		.pipe(mocha());
});

gulp.task('default',['html','css','js']);
<commit_msg>fix: css watch in gulpfile<commit_after>var gulp=require('gulp');
var reload=require('require-reload')(require);
var notify=require('gulp-notify');
var file=require('gulp-file');
var browserify=require('browserify');
var source=require('vinyl-source-stream');
var buffer=require('vinyl-buffer');
var sourcemaps=require('gulp-sourcemaps');
var wrapJS=require('gulp-wrap-js');
var uglify=require('gulp-uglify');
var less=require('gulp-less');
var autoprefixer=require('gulp-autoprefixer');
var minifyCss=require('gulp-minify-css');
var mocha=require('gulp-mocha');

var demoDestination='public_html/en/base';
var libDestination='public_html/lib';

// https://github.com/greypants/gulp-starter/blob/master/gulp/util/handleErrors.js
function handleErrors() {
	var args=Array.prototype.slice.call(arguments);
	notify.onError({
		title: "Compile Error",
		message: "<%= error %>"
	}).apply(this,args);
	this.emit('end');
}

gulp.task('html',function(){
	return file(
		'index.html',
		reload('./demos/template.js')(
			"WebGL starter code generator",
			['http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.7/styles/default.min.css'],
			['http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.7/highlight.min.js']
		),
		{src: true}
	)
		.pipe(gulp.dest(demoDestination));
});

gulp.task('css',function(){
	gulp.src('src/webgl-starter.less')
		.pipe(sourcemaps.init())
		.pipe(less())
		.on('error',handleErrors)
		.pipe(autoprefixer())
		.pipe(minifyCss())
		.pipe(sourcemaps.write('.',{
			sourceRoot: '.'
		}))
		.pipe(gulp.dest(libDestination));
});

gulp.task('js',function(){
	browserify({
		entries: 'src/main.js',
		debug: true
	})
		.transform('babelify',{
			presets:['es2015-loose'],
			plugins:['external-helpers-2'],
		})
		.bundle()
		.on('error',handleErrors)
		.pipe(source('webgl-starter.js'))
		.pipe(buffer())
		.pipe(sourcemaps.init({
			loadMaps: true
		}))
		.pipe(wrapJS(
			reload('./src/base/babel-helpers-wrapper.js')()
		))
		.pipe(uglify())
		.pipe(sourcemaps.write('.',{
			sourceRoot: '.'
		}))
		.pipe(gulp.dest(libDestination));
});

gulp.task('watch',function(){
	gulp.watch(['demos/*'],['html']);
	gulp.watch(['src/**/*.js'],['js']);
	gulp.watch(['src/*.less'],['css']);
});

gulp.task('test',function(){
	gulp.src('tests/**/*.js')
		.pipe(mocha());
});

gulp.task('default',['html','css','js']);
<|endoftext|>


<commit_before>'use strict';

const gulp = require('gulp');
const del = require('del');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const cleanCSS = require('gulp-clean-css');
const runSequence = require('run-sequence');
const inlineNg2Template = require('gulp-inline-ng2-template');
const rename = require("gulp-rename");

const paths = {
  all: "./npm-modules/**/*.*",
  tmp: "./tmp",
  sass: "./tmp/**/*.scss",
  css: "./tmp/**/*.css",
  ts: "./tmp/**/*.ts"
};

gulp.task('build-clean', function () {
  return del(paths.tmp);
});

gulp.task('build-rename', function () {
  return gulp.src(paths.css)
    .pipe(rename(function (path) {
      path.extname = ".scss"
    }))
    .pipe(gulp.dest(sameFolder));
});

gulp.task('build-sass', function () {
  return gulp.src(paths.sass)
    .pipe(sass().on('error', sass.logError))
    .pipe(autoprefixer({
      browsers: ['last 2 versions'],
      cascade: false
    }))
    .pipe(cleanCSS())
    .pipe(gulp.dest(sameFolder));
});

gulp.task('build-inline', () => {
  return gulp.src(paths.ts)
    .pipe(inlineNg2Template({ useRelativePaths:true}))
    .pipe(gulp.dest(sameFolder));
});

gulp.task('build-copy-npm-modules', () => {
  return gulp.src(paths.all)
    .pipe(gulp.dest(paths.tmp));
});

gulp.task('build', () => {
  runSequence(
    'build-clean',
    'build-copy-npm-modules',
    'build-sass',
    'build-rename',
    'build-inline'
  );
});

function sameFolder(file) {
  return file.base;
}
<commit_msg>add build script<commit_after>'use strict';

const gulp = require('gulp');
const del = require('del');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const cleanCSS = require('gulp-clean-css');
const runSequence = require('run-sequence');
const inlineNg2Template = require('gulp-inline-ng2-template');
const rename = require("gulp-rename");

const paths = {
  all: "./npm-modules/**/*.*",
  tmp: "./tmp",
  sass: "./tmp/**/*.scss",
  css: "./tmp/**/*.css",
  ts: "./tmp/**/*.ts"
};

gulp.task('build-clean', function () {
  return del(paths.tmp);
});

gulp.task('build-rename', function () {
  return gulp.src(paths.css)
    .pipe(rename(function (path) {
      path.extname = ".scss"
    }))
    .pipe(gulp.dest(sameFolder));
});

gulp.task('build-sass', function () {
  return gulp.src(paths.sass)
    .pipe(sass().on('error', sass.logError))
    .pipe(autoprefixer({
      browsers: ['last 2 versions'],
      cascade: false
    }))
    .pipe(cleanCSS())
    .pipe(gulp.dest(sameFolder));
});

gulp.task('build-inline', () => {
  return gulp.src(paths.ts)
    .pipe(inlineNg2Template({ useRelativePaths:true}))
    .pipe(gulp.dest(sameFolder));
});

gulp.task('build-copy-npm-modules', () => {
  return gulp.src(paths.all)
    .pipe(gulp.dest(paths.tmp));
});

gulp.task('build', () => {
  runSequence(
    'build-clean',
    'build-copy-npm-modules',
    'build-sass',
    'build-rename',
    'build-inline'
  );
});

function sameFolder(file) {
  return file.base;
}
<|endoftext|>


<commit_before>//initialize all of our variables
var app, base, gulp, gutil, gulpSequence, shell, build_deps, path, through2, File;

//load all of our dependencies
//add more here if you want to include more libraries
gulp          = require('gulp');
gutil         = require('gulp-util');
File          = gutil.File;
path          = require('path');
through2      = require('through2');
gulpSequence  = require('gulp-sequence').use(gulp);
shell         = require('gulp-shell');

gulp.task('write-dep-file', shell.task([
  'rm -f dependencies.js',
  'touch dependencies.js;'
]));

gulp.task('write-deps', function () {
  build_deps.get_configs();
});

gulp.task('build-deps', gulpSequence(['write-dep-file', 'write-deps']));

function string_src(filename, string) {
  var src = require('stream').Readable({ objectMode: true })
  src._read = function () {
    this.push(new gutil.File({ cwd: "", base: "", path: filename, contents: new Buffer(string) }))
    this.push(null)
  }
  return src
}

build_deps = {
  get_configs: function () {
    gulp.src('./configs/*.json')
      .pipe(this.build_deps('test'))
      .pipe(gulp.dest('./dependencies/'));
  },

  build_deps: function(modifier) {
    var self = this;
    return through2.obj(function(file, encoding, done) {
      var filename = path.basename(file.path);
      var config = require('./configs/' + filename);

      self.current_retailer = self.get_retailer(filename);
      var dep_string = self.get_deps(config);

      var target_name = self.get_dep_filename(filename);
      var dep = new File({ cwd: "", base: "", path: target_name, contents: new Buffer(dep_string) });
      done(null, dep);
    });
  },

  get_deps: function (config) {
    return JSON.stringify(config);
  },

  get_export_string: function (obj, component) {
    var component_path = this.get_component_path(component)
    return 'import App.' + obj.toLowerCase() + ' from ' + component_path;
  },

  get_component_path: function (component) {
    var basepath = 'app/components/'
    return  basepath + component + '/retailers/' + this.current_retailer + '/' + component + '.js';
  },

  get_retailer: function (filename) {
    var reg = /^configs\.(\w+?).json$/
    return reg.exec(filename)[1];
  },

  get_dep_filename: function (filename) {
    return 'dependencies.' + this.current_retailer + '.js';
  }

}<commit_msg>SF-6269 - Task to build basic full path dependencies<commit_after>//initialize all of our variables
var app, base, gulp, gutil, gulpSequence, shell, build_deps, path, through2, File;

//load all of our dependencies
//add more here if you want to include more libraries
gulp          = require('gulp');
gutil         = require('gulp-util');
File          = gutil.File;
path          = require('path');
through2      = require('through2');
gulpSequence  = require('gulp-sequence').use(gulp);
shell         = require('gulp-shell');

gulp.task('write-dep-file', shell.task([
  'rm -f dependencies.js',
  'touch dependencies.js;'
]));

gulp.task('write-deps', function () {
  build_deps.get_configs();
});

gulp.task('build-deps', gulpSequence(['write-dep-file', 'write-deps']));

function string_src(filename, string) {
  var src = require('stream').Readable({ objectMode: true })
  src._read = function () {
    this.push(new gutil.File({ cwd: "", base: "", path: filename, contents: new Buffer(string) }))
    this.push(null)
  }
  return src
}

build_deps = {
  get_configs: function () {
    gulp.src('./configs/*.json')
      .pipe(this.build_deps('test'))
      .pipe(gulp.dest('./dependencies/'));
  },

  build_deps: function(modifier) {
    var self = this;
    return through2.obj(function(file, encoding, done) {
      var filename = path.basename(file.path);
      var config = require('./configs/' + filename);

      self.current_retailer = self.get_retailer(filename);
      var dep_string = self.get_deps(config);

      var target_name = self.get_dep_filename(filename);
      var dep = new File({ cwd: "", base: "", path: target_name, contents: new Buffer(dep_string) });
      done(null, dep);
    });
  },

  get_deps: function (config) {
    var components = config.components,
        import_strings = "";
        self = this;
    components.forEach(function (obj) {
      import_strings += self.get_export_string(obj)
    });

    return import_strings;
  },

  get_export_string: function (component) {
    var component_path = this.get_component_path(component)
    return 'import App.' + component + ' from ' + component_path + '\n';
  },

  get_component_path: function (component) {
    var basepath = 'app/components/'
    return  basepath + component + '/retailers/' + this.current_retailer + '/' + component + '.js';
  },

  get_retailer: function (filename) {
    var reg = /^configs\.(\w+?).json$/
    return reg.exec(filename)[1];
  },

  get_dep_filename: function (filename) {
    return 'dependencies.' + this.current_retailer + '.js';
  }

}<|endoftext|>


<commit_before>require('es6-promise').polyfill();

var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var sass = require('gulp-sass');
var moduleImporter = require('sass-module-importer');
var autoprefixer = require('gulp-autoprefixer');
var gcmq = require('gulp-group-css-media-queries');;
var cleanCSS = require('gulp-clean-css');
var include = require('gulp-include');
var uglify = require('gulp-uglify');
var del = require('del');
var runSequence = require('run-sequence');
var srcThemesPath = './resources/themes/';
var destThemesPath = './public/assets/';

gulp.task('sass-dev', function() {
  return gulp.src([srcThemesPath + '**/*.scss'])
    .pipe(sourcemaps.init())
    .pipe(sass({ importer: moduleImporter() }).on('error', sass.logError))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest(destThemesPath));
});

gulp.task('sass-prod', function() {
  return gulp.src([srcThemesPath + '**/*.scss'])
    .pipe(sass({ importer: moduleImporter() }).on('error', sass.logError))
    .pipe(autoprefixer({
      browsers: ['last 2 versions'],
      cascade: false
    }))
    .pipe(gcmq())
    .pipe(cleanCSS({debug: true}, function(details) {
      console.log(details.name + ' before: ' + details.stats.originalSize);
      console.log(details.name + ' after: ' + details.stats.minifiedSize);
    }))
    .pipe(gulp.dest(destThemesPath));
});

gulp.task('js', function() {
  return gulp.src([srcThemesPath + '**/*.js'])
    .pipe(include())
    .pipe(include({
      includePaths: [__dirname + "/node_modules"]
    })).on('error', console.log)
    .pipe(uglify())
    .pipe(gulp.dest(destThemesPath));
});

gulp.task('clean', function() {
  return del.sync('./public/assets');
})

gulp.task('watch', function(){
  gulp.watch(srcThemesPath + '**/*.scss', ['sass-dev']);
  gulp.watch(srcThemesPath + '**/*.js', ['js']);
})

// Build Sequences
// ---------------

gulp.task('default', function() {
  runSequence('clean', ['sass-dev', 'js'], 'watch')
})

gulp.task('build', function() {
  runSequence('clean', ['sass-prod', 'js'])
})
<commit_msg>Modify path to node_modules<commit_after>require('es6-promise').polyfill();

var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var sass = require('gulp-sass');
var moduleImporter = require('sass-module-importer');
var autoprefixer = require('gulp-autoprefixer');
var gcmq = require('gulp-group-css-media-queries');;
var cleanCSS = require('gulp-clean-css');
var include = require('gulp-include');
var uglify = require('gulp-uglify');
var del = require('del');
var runSequence = require('run-sequence');
var srcThemesPath = './resources/themes/';
var destThemesPath = './public/assets/';

gulp.task('sass-dev', function() {
  return gulp.src([srcThemesPath + '**/*.scss'])
    .pipe(sourcemaps.init())
    .pipe(sass({ importer: moduleImporter() }).on('error', sass.logError))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest(destThemesPath));
});

gulp.task('sass-prod', function() {
  return gulp.src([srcThemesPath + '**/*.scss'])
    .pipe(sass({ importer: moduleImporter() }).on('error', sass.logError))
    .pipe(autoprefixer({
      browsers: ['last 2 versions'],
      cascade: false
    }))
    .pipe(gcmq())
    .pipe(cleanCSS({debug: true}, function(details) {
      console.log(details.name + ' before: ' + details.stats.originalSize);
      console.log(details.name + ' after: ' + details.stats.minifiedSize);
    }))
    .pipe(gulp.dest(destThemesPath));
});

gulp.task('js', function() {
  return gulp.src([srcThemesPath + '**/*.js'])
    .pipe(include())
    .pipe(include({
      includePaths: ['./node_modules']
    })).on('error', console.log)
    .pipe(uglify())
    .pipe(gulp.dest(destThemesPath));
});

gulp.task('clean', function() {
  return del.sync('./public/assets');
})

gulp.task('watch', function(){
  gulp.watch(srcThemesPath + '**/*.scss', ['sass-dev']);
  gulp.watch(srcThemesPath + '**/*.js', ['js']);
})

// Build Sequences
// ---------------

gulp.task('default', function() {
  runSequence('clean', ['sass-dev', 'js'], 'watch')
})

gulp.task('build', function() {
  runSequence('clean', ['sass-prod', 'js'])
})
<|endoftext|>


<commit_before>'use strict';

var gulp       = require('gulp');
var source     = require('vinyl-source-stream');
var browserify = require('browserify');
var babelify   = require('babelify');
var babel      = require('gulp-babel');
var server     = require('gulp-webserver');
var sass       = require('gulp-sass');
var concat     = require('gulp-concat');
var rename     = require('gulp-rename');
var uglify     = require('gulp-uglify');
var eslint     = require('gulp-eslint');
var replace    = require('gulp-replace');
var minifyCSS  = require('gulp-minify-css');

var config = {
  componentFileName: 'react-star-rating',
  componentSrc: './src/StarRating.jsx',
  componentStylesDir: './src/sass',
  stylesDest: './dist/css'
};

/**
 * Lint
 */
gulp.task('lint', function () {
  return gulp.src('./src/**/*.{jsx, js}')
    .pipe(eslint({
      useEslintrc: true
    }))
    .pipe(eslint.format())
    .pipe(eslint.failOnError());
});

/**
 * Styles
 */
gulp.task('styles', ['demo-styles'], function () {
  return gulp.src(config.componentStylesDir + '/' + config.componentFileName + '.scss')
    .pipe(sass({
      includePaths: require('node-bourbon').includePaths
    }))
    .pipe(gulp.dest(config.stylesDest))
    .pipe(minifyCSS())
    .pipe(rename(config.componentFileName + '.min.css'))
    .pipe(gulp.dest(config.stylesDest));
});

/**
 * Build
 */
gulp.task('build', ['lint'], function () {
  return gulp.src(config.componentSrc)
    .pipe(babel())
    .pipe(rename(config.componentFileName + '.js'))
    .pipe(gulp.dest('dist'))
    .pipe(rename(config.componentFileName + '.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('dist'));
});

/**
 * Demo Styles
 */
gulp.task('demo-styles', function () {
  return gulp.src(config.componentStylesDir + '/demo.scss')
    .pipe(sass({
      includePaths: require('node-bourbon').includePaths
    }))
    .pipe(gulp.dest(config.stylesDest));
});

/**
 * Demo Bundle
 */
gulp.task('default', ['lint', 'styles'], function () {
  return browserify('./src/docs.jsx', {extensions: '.jsx'})
    .transform(babelify)
    .bundle()
    .on('error', function (err) {
      console.log(err);
    })
    .pipe(source('docs.js'))
    .pipe(gulp.dest('dist'));
});

/**
 * Watch
 */
gulp.task('watch', ['default'], function () {
  gulp.watch(['./src/*.js', './src/**/*.jsx', './src/sass/{*/,}*.scss'], ['dist']);
  return gulp.src('.').pipe(server());
});

/**
 * Dist
 */
gulp.task('dist', ['default', 'styles', 'build']);
<commit_msg>change gulp file<commit_after>'use strict';

var gulp       = require('gulp');
var source     = require('vinyl-source-stream');
var browserify = require('browserify');
var babelify   = require('babelify');
var babel      = require('gulp-babel');
var server     = require('gulp-webserver');
var sass       = require('gulp-sass');
var concat     = require('gulp-concat');
var rename     = require('gulp-rename');
var uglify     = require('gulp-uglify');
var eslint     = require('gulp-eslint');
var replace    = require('gulp-replace');
var minifyCSS  = require('gulp-minify-css');

var config = {
  componentFileName: 'react-star-rating',
  componentSrc: './src/StarRating.jsx',
  componentStylesDir: './src/sass',
  stylesDest: './dist/css'
};

/**
 * Lint
 */
gulp.task('lint', function () {
  return gulp.src('./src/**/*.{jsx, js}')
    .pipe(eslint({
      useEslintrc: true
    }))
    .pipe(eslint.format())
    .pipe(eslint.failOnError());
});

/**
 * Styles
 */
gulp.task('styles', ['demo-styles'], function () {
  return gulp.src(config.componentStylesDir + '/' + config.componentFileName + '.scss')
    .pipe(sass({
      includePaths: require('node-bourbon').includePaths
    }))
    .pipe(gulp.dest(config.stylesDest))
    .pipe(minifyCSS())
    .pipe(rename(config.componentFileName + '.min.css'))
    .pipe(gulp.dest(config.stylesDest));
});

/**
 * Build
 */
gulp.task('build', ['lint'], function () {
  return gulp.src(config.componentSrc)
    .pipe(babel())
    .pipe(rename(config.componentFileName + '.js'))
    .pipe(gulp.dest('dist'))
    .pipe(rename(config.componentFileName + '.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('dist'));
});

/**
 * Demo Styles
 */
gulp.task('demo-styles', function () {
  return gulp.src(config.componentStylesDir + '/demo.scss')
    .pipe(sass({
      includePaths: require('node-bourbon').includePaths
    }))
    .pipe(gulp.dest(config.stylesDest));
});

/**
 * Demo Bundle
 */
gulp.task('default', ['lint', 'styles'], function () {
  return browserify('./src/docs.jsx', {extensions: '.jsx'})
    .transform(babelify)
    .bundle()
    .on('error', function (err) {
      console.log(err);
    })
    .pipe(source('docs.js'))
    .pipe(gulp.dest('dist'));
});

/**
 * Watch
 */
gulp.task('watch', ['default'], function () {
  gulp.watch(['./src/*.js', './src/**/*.jsx', './src/sass/{*/,}*.scss'], ['dist']);
  return gulp.src('.').pipe(server({
    port: 3000
  }));
});

/**
 * Dist
 */
gulp.task('dist', ['default', 'styles', 'build']);
<|endoftext|>


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

var sourceDir = "./nectd/source/",
    themeDir = "./theme/nectd-2015/",
    outDir = "./www/assets/";

var static = {
    sourceDir : "./nectd/source/",
    outDir : "./static/nectd/assets/"
}

var minifyCss = require("gulp-minify-css");
var sourcemaps = require("gulp-sourcemaps");
var rename = require("gulp-rename");

gulp.task("static", function () {
    var sass = require("gulp-sass");

    gulp.src(static.sourceDir + "scss/*.scss")
        .pipe(sass().on("error", sass.logError))
        .pipe(minifyCss())
        .pipe(gulp.dest(static.outDir + "css"));
});

gulp.task("scss", function () {
    var sass = require("gulp-sass");

    gulp.src(sourceDir + "scss/*.scss")
        .pipe(sass().on("error", sass.logError))
        .pipe(minifyCss())
        .pipe(gulp.dest(outDir + "css"));
});

gulp.task("fonts", function() {
    gulp.src("node_modules/font-awesome/fonts/*")
        .pipe(gulp.dest(outDir + "fonts"));
});

gulp.task("build-js", function() {
    var browserify = require("browserify");
    var babelify = require("babelify");
    var source = require("vinyl-source-stream");
    // var buffer = require("vinyl-buffer");
    // var uglify = require("gulp-uglify");

    return browserify({
            entries: sourceDir + "nectd-app.js",
            debug: true,
            transform: [ babelify ]
        })
        .bundle()
        .pipe(source("nectd-app.js"))
        // .pipe(buffer())
        // .pipe(sourcemaps.init({loadMaps: true}))
        //     .pipe(uglify())
        // .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest(outDir + "js"));
});

gulp.task("bolt-js", function() {
    var uglify = require("gulp-uglify");

    gulp.src(themeDir + "**/*.{js,htc}")
        .pipe(rename({ dirname: "" }))
        // .pipe(uglify())
        .pipe(gulp.dest(outDir + "js"));
});

gulp.task("bolt-css", function() {
    var uglify = require("gulp-uglify");

    gulp.src(themeDir + "**/*.css")
        .pipe(rename({ dirname: "" }))
        .pipe(minifyCss())
        .pipe(gulp.dest(outDir + "css"));
});

gulp.task("bolt-img", function() {
    var imagemin = require("gulp-imagemin");

    gulp.src(themeDir + "**/*.{jpg,png,gif}")
        .pipe(rename({ dirname: "" }))
        .pipe(imagemin())
        .pipe(gulp.dest(outDir + "img"));
});

gulp.task("bolt-stuff", [ "bolt-css", "bolt-js", "bolt-img" ], function() {
    gulp.src(themeDir + "old_web/fonts/*")
        .pipe(gulp.dest(outDir + "fonts"));
    gulp.src(themeDir + "web-cards/assets/css/images/*")
        .pipe(gulp.dest(outDir + "css/images"));
});

gulp.task("avatars", function() {
    var imagemin = require("gulp-imagemin");

    gulp.src("nectd/avatars/*.{jpg,png,gif}")
        .pipe(imagemin())
        .pipe(gulp.dest(outDir + "avatars"));
})

var watch = require("gulp-watch");

gulp.task("watch-scss", function() {
    watch(sourceDir + "scss/**/*.scss", function() {
        gulp.start("scss");
    });
});

gulp.task("watch-static", function() {
    watch(sourceDir + "scss/**/*.scss", function() {
        gulp.start("static");
    });
});

gulp.task("build", [ "bolt-stuff", "scss", "build-js", "fonts", "avatars", "static" ]);
<commit_msg>Watcher tasks; imagemin<commit_after>var gulp = require("gulp");

var sourceDir = "./nectd/source/",
    themeDir = "./theme/nectd-2015/",
    outDir = "./www/assets/";

var static = {
    sourceDir : "./nectd/source/",
    outDir : "./static/nectd/assets/"
}

var minifyCss = require("gulp-minify-css");
var sourcemaps = require("gulp-sourcemaps");
var rename = require("gulp-rename");

gulp.task("static", function () {
    var sass = require("gulp-sass");

    gulp.src(static.sourceDir + "scss/*.scss")
        .pipe(sass().on("error", sass.logError))
        .pipe(minifyCss())
        .pipe(gulp.dest(static.outDir + "css"));
});

gulp.task("scss", function () {
    var sass = require("gulp-sass");

    gulp.src(sourceDir + "scss/*.scss")
        .pipe(sass().on("error", sass.logError))
        .pipe(minifyCss())
        .pipe(gulp.dest(outDir + "css"));
});

gulp.task("fonts", function() {
    gulp.src("node_modules/font-awesome/fonts/*")
        .pipe(gulp.dest(outDir + "fonts"));
});

gulp.task("build-js", function() {
    var browserify = require("browserify");
    var babelify = require("babelify");
    var source = require("vinyl-source-stream");
    // var buffer = require("vinyl-buffer");
    // var uglify = require("gulp-uglify");

    return browserify({
            entries: sourceDir + "nectd-app.js",
            debug: true,
            transform: [ babelify ]
        })
        .bundle()
        .pipe(source("nectd-app.js"))
        // .pipe(buffer())
        // .pipe(sourcemaps.init({loadMaps: true}))
        //     .pipe(uglify())
        // .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest(outDir + "js"));
});

gulp.task("imagemin", function() {
    var imagemin = require("gulp-imagemin");

    gulp.src(sourceDir + "images/**/*.{jpg,png,gif}")
        .pipe(imagemin())
        .pipe(gulp.dest(outDir + "img"));
});

gulp.task("bolt-js", function() {
    var uglify = require("gulp-uglify");

    gulp.src(themeDir + "**/*.{js,htc}")
        .pipe(rename({ dirname: "" }))
        // .pipe(uglify())
        .pipe(gulp.dest(outDir + "js"));
});

gulp.task("bolt-css", function() {
    var uglify = require("gulp-uglify");

    gulp.src(themeDir + "**/*.css")
        .pipe(rename({ dirname: "" }))
        .pipe(minifyCss())
        .pipe(gulp.dest(outDir + "css"));
});

gulp.task("bolt-img", function() {
    var imagemin = require("gulp-imagemin");

    gulp.src(themeDir + "**/*.{jpg,png,gif}")
        .pipe(rename({ dirname: "" }))
        .pipe(imagemin())
        .pipe(gulp.dest(outDir + "img"));
});

gulp.task("bolt-stuff", [ "bolt-css", "bolt-js", "bolt-img" ], function() {
    gulp.src(themeDir + "old_web/fonts/*")
        .pipe(gulp.dest(outDir + "fonts"));
    gulp.src(themeDir + "web-cards/assets/css/images/*")
        .pipe(gulp.dest(outDir + "css/images"));
});

gulp.task("avatars", function() {
    var imagemin = require("gulp-imagemin");

    gulp.src("nectd/avatars/*.{jpg,png,gif}")
        .pipe(imagemin())
        .pipe(gulp.dest(outDir + "avatars"));
})

var watch = require("gulp-watch");

gulp.task("watch-scss", function() {
    watch(sourceDir + "scss/**/*.scss", function() {
        gulp.start("scss");
    });
});

gulp.task("watch-js", function() {
    watch(sourceDir + "**/*.js", function() {
        gulp.start("build-js");
    });
});

gulp.task("watch-img", function() {
    watch(sourceDir + "images/**/*.{jpg,png,gif}", function() {
        gulp.start("imagemin");
    });
});

gulp.task("watch", [ "watch-scss", "watch-js" ]);

gulp.task("watch-static", function() {
    watch(sourceDir + "scss/**/*.scss", function() {
        gulp.start("static");
    });
});

gulp.task("build", [ "bolt-stuff", "scss", "build-js", "fonts", "avatars", "static" ]);
<|endoftext|>


<commit_before>let isEnabled = false;

export function requestPermission() {
    // Do we support notifications?
    if (!('Notification' in window)) {
        isEnabled = false;
    }

    // Permissions already been granted?
    if (Notification.permission === 'granted') {
        isEnabled = true;
    }

    if (Notification.permission !== 'denied') {
        Notification.requestPermission(permission => {
            if (permission === 'granted') {
                isEnabled = true;
            } else {
                isEnabled = false;
            }
        });
    }
}

export function show(title, body, opts) {
    if (!isEnabled) {
        return false;
    }

    let notify = new Notification(title, {
        body: body,
        icon: opts.icon,
    });

    if (opts.ttl) {
        setTimeout(notify.close.bind(notify), opts.ttl);
    }

    return notify;
}

export function listenForNewMessages(state) {
    state.$on('message.new', (message, buffer) => {
        if (!isEnabled) {
            return;
        }

        let network = state.getNetwork(buffer.networkid);
        let isHighlight = message.message.indexOf(network.nick) > -1;
        let settingAlertOn = buffer.setting('alert_on');
        let notification = null;
        let notifyMessage = message.nick ?
                message.nick + ': ' :
                '';
        notifyMessage += message.message;

        if ((settingAlertOn === 'message' || settingAlertOn === 'highlight') && isHighlight) {
            notification = show('You were mentioned in ' + buffer.name, notifyMessage, {
                ttl: 7000,
            });
        } else if (settingAlertOn === 'message' && !isHighlight) {
            notification = show(buffer.name, notifyMessage, {
                ttl: 7000,
            });
        } else if (settingAlertOn === 'never') {
            // Don't do anything
        }

        if (notification) {
            notification.onclick = () => {
                state.setActiveBuffer(buffer.networkid, buffer.name);
            };
        }
    });
}
<commit_msg>Don't show highlight notifications if it's the current user joining/parting<commit_after>let isEnabled = false;

export function requestPermission() {
    // Do we support notifications?
    if (!('Notification' in window)) {
        isEnabled = false;
    }

    // Permissions already been granted?
    if (Notification.permission === 'granted') {
        isEnabled = true;
    }

    if (Notification.permission !== 'denied') {
        Notification.requestPermission(permission => {
            if (permission === 'granted') {
                isEnabled = true;
            } else {
                isEnabled = false;
            }
        });
    }
}

export function show(title, body, opts) {
    if (!isEnabled) {
        return false;
    }

    let notify = new Notification(title, {
        body: body,
        icon: opts.icon,
    });

    if (opts.ttl) {
        setTimeout(notify.close.bind(notify), opts.ttl);
    }

    return notify;
}

export function listenForNewMessages(state) {
    state.$on('message.new', (message, buffer) => {
        if (!isEnabled) {
            return;
        }

        let network = state.getNetwork(buffer.networkid);
        let isHighlight = message.message.indexOf(network.nick) > -1;
        let settingAlertOn = buffer.setting('alert_on');
        let notification = null;
        let notifyMessage = message.nick ?
                message.nick + ': ' :
                '';
        notifyMessage += message.message;

        // Ignore our own join/parts
        if (message.type === 'traffic' && message.nick === network.nick) {
            return;
        }

        if ((settingAlertOn === 'message' || settingAlertOn === 'highlight') && isHighlight) {
            notification = show('You were mentioned in ' + buffer.name, notifyMessage, {
                ttl: 7000,
            });
        } else if (settingAlertOn === 'message' && !isHighlight) {
            notification = show(buffer.name, notifyMessage, {
                ttl: 7000,
            });
        } else if (settingAlertOn === 'never') {
            // Don't do anything
        }

        if (notification) {
            notification.onclick = () => {
                state.setActiveBuffer(buffer.networkid, buffer.name);
            };
        }
    });
}
<|endoftext|>


<commit_before>var gulp = require('gulp');
var gutil = require('gulp-util');
var bower = require('bower');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var sh = require('shelljs');

var clean = require('gulp-clean');
var jshint = require('gulp-jshint');
var ngAnnotate = require('gulp-ng-annotate');
var uglify = require("gulp-uglify");
var imagemin = require('gulp-imagemin');
var htmlreplace = require('gulp-html-replace');
var templateCache = require('gulp-angular-templatecache');
var wiredep = require('wiredep');
var usemin = require('gulp-usemin');
var minifyHtml = require('gulp-minify-html');
var rev = require('gulp-rev');
var install = require("gulp-install");

var paths = {
  sass: ['./scss/**/*.scss'],
  scripts: ['./www/js/**/*.js', '!./www/js/app.bundle.min.js'], // exclude the file we write too
  images: ['./www/img/**/*'],
  templates: ['./www/templates/**/*.html'],
  css: ['./www/css/**/*.min.css'],
  html: ['./www/index.html'],
  fonts: ['./www/lib/ionic/fonts/*'],
  lib: ['./www/lib/parse-1.2.18.min.js', './www/lib/moment.min.js', './www/lib/bindonce.min.js'],
  www: ['./www/'],
  dist: ['./dist/']
};
// Check the project is up to date.
gulp.task('git-check', function(done) {
  if (!sh.which('git')) {
    console.log(
      '  ' + gutil.colors.red('Git is not installed.'),
      '\n  Git, the version control system, is required to download Ionic.',
      '\n  Download git here:', gutil.colors.cyan('http://git-scm.com/downloads') + '.',
      '\n  Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.'
    );
    process.exit(1);
  }
  done();
});
// Install npm packages.
gulp.task('npm', function(done) {
  gulp.src(['./package.json'])
    .pipe(install());
});
// Install bower dependenices.
gulp.task('bower', function () {
  bower.commands.install()
    .on('log', function(data) {
      gutil.log('bower', gutil.colors.cyan(data.id), data.message);
    });
});
// Set bower dependencies.
gulp.task('wiredep', function(){
  gulp.src(paths.html)
    .pipe(wiredep.stream())
    .pipe(gulp.dest(paths.www + './'));
});
gulp.task('install', ['git-check', 'npm', 'bower', 'wiredep']);

// Build sass file.
gulp.task('sass', function(done) {
  gulp.src('./scss/ionic.app.scss')
    .pipe(sass({
      errLogToConsole: true
    }))
    .pipe(gulp.dest(paths.www + 'css/'))
    .on('end', done);
});

// concat all html templates and load into templateCache
gulp.task('templateCache', function() {
  gulp.src(paths.templates)
    .pipe(templateCache({
      'filename': 'templates.js',
      'root': 'templates/',
      'module': 'app'
    }))
    .pipe(gulp.dest(paths.www + 'js'))
  done();
});

gulp.task('jshint', function() {
  gulp.src(paths.scripts)
    .pipe(jshint())
    .pipe(jshint.reporter('default'));
});
gulp.task('watch', function() {
  gulp.watch(paths.sass, ['sass']);
  gulp.watch(paths.templates, ['templateCache']);
  gulp.watch(paths.scripts, ['scripts']);
});
gulp.task('default', ['sass', 'templateCache']);

gulp.task('clean', function(done) {
  gulp.src(paths.dist, { read: false })
    .pipe(clean());
  done();
});

gulp.task('usemin', ['clean', 'sass', 'templateCache'], function (done) {
  gulp.src(paths.html)
    .pipe(usemin({
      html: [minifyHtml({empty: true})],
      css: [minifyCss(), 'concat', rev()],
      jsVendor: [uglify(), rev()],
      jsApp: [
        ngAnnotate({remove: true, add: true, single_quotes: true }),
        jshint(),
        jshint.reporter('default'),
        uglify(),
        rev()
      ]
    }))
    .pipe(gulp.dest(paths.dist + ''));
  done();
});
// Imagemin images and ouput them in dist
gulp.task('imagemin', function() {
  gulp.src(paths.images)
    .pipe(imagemin())
    .pipe(gulp.dest(paths.dist + 'img'));
});

gulp.task('copy', function() {
  gulp.src(paths.fonts, {base: paths.www + ''})
    .pipe(gulp.dest(paths.dist + ''));
});

gulp.task('build', ['clean'], function(){
  gulp.start('usemin');
  gulp.start('imagemin');
  gulp.start('copy');
});<commit_msg>fix gulp templateCache<commit_after>var gulp = require('gulp');
var gutil = require('gulp-util');
var bower = require('bower');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var sh = require('shelljs');

var clean = require('gulp-clean');
var jshint = require('gulp-jshint');
var ngAnnotate = require('gulp-ng-annotate');
var uglify = require("gulp-uglify");
var imagemin = require('gulp-imagemin');
var htmlreplace = require('gulp-html-replace');
var templateCache = require('gulp-angular-templatecache');
var wiredep = require('wiredep');
var usemin = require('gulp-usemin');
var minifyHtml = require('gulp-minify-html');
var rev = require('gulp-rev');
var install = require("gulp-install");

var paths = {
  sass: ['./scss/**/*.scss'],
  scripts: ['./www/js/**/*.js', '!./www/js/app.bundle.min.js'], // exclude the file we write too
  images: ['./www/img/**/*'],
  templates: ['./www/templates/**/*.html'],
  css: ['./www/css/**/*.min.css'],
  html: ['./www/index.html'],
  fonts: ['./www/lib/ionic/fonts/*'],
  lib: ['./www/lib/parse-1.2.18.min.js', './www/lib/moment.min.js', './www/lib/bindonce.min.js'],
  www: ['./www/'],
  dist: ['./dist/']
};
// Check the project is up to date.
gulp.task('git-check', function(done) {
  if (!sh.which('git')) {
    console.log(
      '  ' + gutil.colors.red('Git is not installed.'),
      '\n  Git, the version control system, is required to download Ionic.',
      '\n  Download git here:', gutil.colors.cyan('http://git-scm.com/downloads') + '.',
      '\n  Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.'
    );
    process.exit(1);
  }
  done();
});
// Install npm packages.
gulp.task('npm', function(done) {
  gulp.src(['./package.json'])
    .pipe(install());
});
// Install bower dependenices.
gulp.task('bower', function () {
  bower.commands.install()
    .on('log', function(data) {
      gutil.log('bower', gutil.colors.cyan(data.id), data.message);
    });
});
// Set bower dependencies.
gulp.task('wiredep', function(){
  gulp.src(paths.html)
    .pipe(wiredep.stream())
    .pipe(gulp.dest(paths.www + './'));
});
gulp.task('install', ['git-check', 'npm', 'bower', 'wiredep']);

// Build sass file.
gulp.task('sass', function(done) {
  gulp.src('./scss/ionic.app.scss')
    .pipe(sass({
      errLogToConsole: true
    }))
    .pipe(gulp.dest(paths.www + 'css/'))
    .on('end', done);
});

// concat all html templates and load into templateCache
gulp.task('templateCache', function(done) {
  gulp.src(paths.templates)
    .pipe(templateCache({
      'filename': 'templates.js',
      'root': 'templates/',
      'module': 'app'
    }))
    .pipe(gulp.dest(paths.www + 'js'))
    .on('end', done);
});

gulp.task('jshint', function() {
  gulp.src(paths.scripts)
    .pipe(jshint())
    .pipe(jshint.reporter('default'));
});
gulp.task('watch', function() {
  gulp.watch(paths.sass, ['sass']);
  gulp.watch(paths.templates, ['templateCache']);
  gulp.watch(paths.scripts, ['scripts']);
});
gulp.task('default', ['sass', 'templateCache']);

gulp.task('clean', function(done) {
  gulp.src(paths.dist, { read: false })
    .pipe(clean());
  done();
});

gulp.task('usemin', ['clean', 'sass', 'templateCache'], function (done) {
  gulp.src(paths.html)
    .pipe(usemin({
      html: [minifyHtml({empty: true})],
      css: [minifyCss(), 'concat', rev()],
      jsVendor: [uglify(), rev()],
      jsApp: [
        ngAnnotate({remove: true, add: true, single_quotes: true }),
        jshint(),
        jshint.reporter('default'),
        uglify(),
        rev()
      ]
    }))
    .pipe(gulp.dest(paths.dist + ''));
  done();
});
// Imagemin images and ouput them in dist
gulp.task('imagemin', function() {
  gulp.src(paths.images)
    .pipe(imagemin())
    .pipe(gulp.dest(paths.dist + 'img'));
});

gulp.task('copy', function() {
  gulp.src(paths.fonts, {base: paths.www + ''})
    .pipe(gulp.dest(paths.dist + ''));
});

gulp.task('build', ['clean'], function(){
  gulp.start('usemin');
  gulp.start('imagemin');
  gulp.start('copy');
});<|endoftext|>


<commit_before>var gulp = require('gulp'),
    plumber = require('gulp-plumber'),
    compass = require('gulp-compass'),
    browserSync = require('browser-sync'),
    reload      = browserSync.reload,
    concat = require('gulp-concat'),
    imagemin = require('gulp-imagemin'),
    pngquant = require('imagemin-pngquant'),
    jade = require('gulp-jade');
    // sass = require('gulp-sass');

gulp.task('browser-sync', function() {
  browserSync({
    server: {
      baseDir: "./dist"
    }
  });
});

gulp.task('compass', function() {
    return gulp.src('./assets/scss/*.scss')
        .pipe(plumber())
        .pipe(compass({
            css: 'dist/stylesheets',
            sass: 'assets/scss',
            style: 'nested'
        }))
        .pipe(gulp.dest('dist/css'))
});

gulp.task('compass-min', function() {
    return gulp.src('./assets/scss/*.scss')
        .pipe(plumber())
        .pipe(compass({
            css: 'production/css',
            sass: 'assets/scss',
            style: 'compressed'
        }))
        .pipe(concat('main.css'))
        .pipe(gulp.dest('production/css'));
});

// Gulp default task for javascript

gulp.task('js', function() {
  return gulp.src('assets/js/*.js')
    .pipe( gulp.dest('dist/js/'));
});

// Gulp production task for javascript

gulp.task('js-min', function() {
  return gulp.src('assets/js/*.js')
    .pipe(concat('main.js'))
    .pipe( gulp.dest('production/js/'));
});

// Gulp default task for images

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

// Gulp production task for images

gulp.task('images-min', function() {
  return gulp.src('./assets/images/*')
    .pipe(imagemin({
      progressive: true,
      svgoPlugins: [{removeViewBox: false}],
      use: [pngquant()]
    }))
    .pipe(gulp.dest('./production/images'))
})

// Gulp default task for templates

gulp.task('templates', function() {
  return gulp.src('assets/*.jade')
    .pipe(plumber())
    .pipe(jade({
      pretty: true
    }))
    .pipe( gulp.dest('dist/') );
});

// Gulp production task for templates

gulp.task('templates-prod', function() {
  return gulp.src('assets/*.jade')
    .pipe(plumber())
    .pipe(jade({
      pretty: true
    }))
    .pipe( gulp.dest('production/') );
});

// Gulp default task

gulp.task('default',['compass','js','templates', 'images', 'browser-sync'], function () {

  gulp.watch('assets/scss/*.scss',['compass', reload]);

  gulp.watch('assets/scripts/*.js',['js', reload]);

  gulp.watch('assets/images/**/*',['images', reload]);

  gulp.watch('assets/*.jade',['templates', reload]);

});

// Gulp production task

gulp.task('production',['compass-min','js-min','templates-prod', 'images-min'], function () {

});
<commit_msg>Added support for fonts<commit_after>var gulp = require('gulp'),
    plumber = require('gulp-plumber'),
    compass = require('gulp-compass'),
    browserSync = require('browser-sync'),
    reload      = browserSync.reload,
    concat = require('gulp-concat'),
    imagemin = require('gulp-imagemin'),
    pngquant = require('imagemin-pngquant'),
    jade = require('gulp-jade');
    // sass = require('gulp-sass');

gulp.task('browser-sync', function() {
  browserSync({
    server: {
      baseDir: "./dist"
    }
  });
});

gulp.task('compass', function() {
    return gulp.src('./assets/scss/*.scss')
        .pipe(plumber())
        .pipe(compass({
            css: 'dist/stylesheets',
            sass: 'assets/scss',
            style: 'nested'
        }))
        .pipe(gulp.dest('dist/css'))
});

gulp.task('compass-min', function() {
    return gulp.src('./assets/scss/*.scss')
        .pipe(plumber())
        .pipe(compass({
            css: 'production/css',
            sass: 'assets/scss',
            style: 'compressed'
        }))
        .pipe(concat('main.css'))
        .pipe(gulp.dest('production/css'));
});

// Gulp default task for fonts

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

// Gulp production task for javascript

gulp.task('fonts-min', function(){
  return gulp.src('assets/fonts/**/*')
    .pipe( gulp.dest('production/fonts/'));
});

// Gulp default task for javascript

gulp.task('js', function() {
  return gulp.src('assets/js/*.js')
    .pipe( gulp.dest('dist/js/'));
});

// Gulp production task for javascript

gulp.task('js-min', function() {
  return gulp.src('assets/js/*.js')
    .pipe(concat('main.js'))
    .pipe( gulp.dest('production/js/'));
});

// Gulp default task for images

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

// Gulp production task for images

gulp.task('images-min', function() {
  return gulp.src('./assets/images/*')
    .pipe(imagemin({
      progressive: true,
      svgoPlugins: [{removeViewBox: false}],
      use: [pngquant()]
    }))
    .pipe(gulp.dest('./production/images'))
})

// Gulp default task for templates

gulp.task('templates', function() {
  return gulp.src('assets/*.jade')
    .pipe(plumber())
    .pipe(jade({
      pretty: true
    }))
    .pipe( gulp.dest('dist/') );
});

// Gulp production task for templates

gulp.task('templates-prod', function() {
  return gulp.src('assets/*.jade')
    .pipe(plumber())
    .pipe(jade({
      pretty: true
    }))
    .pipe( gulp.dest('production/') );
});

// Gulp default task

gulp.task('default',['compass','js','templates', 'images', 'browser-sync'], function () {

  gulp.watch('assets/scss/*.scss',['compass', reload]);

  gulp.watch('assets/fonts/**/*',['fonts', reload]);

  gulp.watch('assets/scripts/*.js',['js', reload]);

  gulp.watch('assets/images/**/*',['images', reload]);

  gulp.watch('assets/*.jade',['templates', reload]);

});

// Gulp production task

gulp.task('production',['compass-min','fonts-min','js-min','templates-prod', 'images-min'], function () {

});
<|endoftext|>