<commit_before>'use strict';

const fs = require('fs');

const gulp = require('gulp');
const handlebars = require('gulp-compile-handlebars');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
const pump = require('pump');

/**
 * load a bunch of files.
 *
 * @param {object} manifest An object specifying the files you want to load
 * @returns {object} An object containing the contents of the files
 */
function loadFiles(manifest) {

    let files = [];
    for ( let name in manifest ) {
        files.push({
            path: manifest[name],
            name: name
        });
    }

    const tasks = files.map((file) => {

        return new Promise((resolve, reject) => {

            fs.readFile(file.path, {encoding: 'utf-8'}, function(err, data) {
                if ( err ) {
                    reject(err);
                } else {
                    resolve(data);
                }
            });
        });
    });

    return Promise.all(tasks)
        .catch((err) => {

            throw err;
        })
        .then((results) => {

            let finalOut = {};
            for ( let i = 0; i < results.length; ++i ) {
                finalOut[files[i].name] = results[i];
            }
            return finalOut;
        });
}

gulp.task('build', function() {
    return loadFiles({
        ent: 'entities.json',
        chars: 'chars.txt'
    }).then((result) => {

        const ent = JSON.parse(result.ent);
        let chars = result.chars.split('');
        chars = chars.map(function(c) {
            return ent[c] || c;
        });

        const data = {
            symbols: chars
        };

        const options = {
            compile: {
                noEscape: true
            },
            helpers: {
                chars: function() {
                    const result = [];
                    for ( let i = 0; i < this.symbols.length; ++i ) {
                        result.push("\"" + this.symbols[i] + "\"");
                    }
                    return "[" + result.toString() + "]";
                }
            }
        };

        return gulp.src('src/*.js')
            .pipe(handlebars(data, options))
            .pipe(gulp.dest('dist/'))
    }).catch((err) => {

        throw err;
    });
});

gulp.task('minify', ['build'], (cb) => {
    const uglifyOpts = {
        preserveComments: 'license'
    };

    /**
     * gulp-uglify recommends the use of the `pump` module
     * for better error reporting
     *
     * https://github.com/terinjokes/gulp-uglify/tree/master/docs/why-use-pump
     */
    pump([
        gulp.src('dist/*[!.min].js'),
        uglify(uglifyOpts),
        rename({suffix: '.min'}),
        gulp.dest('dist/')
    ], cb);
});

gulp.task('default', ['build', 'minify']);
<commit_msg>add watch task<commit_after>'use strict';

const fs = require('fs');

const gulp = require('gulp');
const handlebars = require('gulp-compile-handlebars');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
const pump = require('pump');

/**
 * load a bunch of files.
 *
 * @param {object} manifest An object specifying the files you want to load
 * @returns {object} An object containing the contents of the files
 */
function loadFiles(manifest) {

    let files = [];
    for ( let name in manifest ) {
        files.push({
            path: manifest[name],
            name: name
        });
    }

    const tasks = files.map((file) => {

        return new Promise((resolve, reject) => {

            fs.readFile(file.path, {encoding: 'utf-8'}, function(err, data) {
                if ( err ) {
                    reject(err);
                } else {
                    resolve(data);
                }
            });
        });
    });

    return Promise.all(tasks)
        .catch((err) => {

            throw err;
        })
        .then((results) => {

            let finalOut = {};
            for ( let i = 0; i < results.length; ++i ) {
                finalOut[files[i].name] = results[i];
            }
            return finalOut;
        });
}

gulp.task('build', function() {
    return loadFiles({
        ent: 'entities.json',
        chars: 'chars.txt'
    }).then((result) => {

        const ent = JSON.parse(result.ent);
        let chars = result.chars.split('');
        chars = chars.map(function(c) {
            return ent[c] || c;
        });

        const data = {
            symbols: chars
        };

        const options = {
            compile: {
                noEscape: true
            },
            helpers: {
                chars: function() {
                    const result = [];
                    for ( let i = 0; i < this.symbols.length; ++i ) {
                        result.push("\"" + this.symbols[i] + "\"");
                    }
                    return "[" + result.toString() + "]";
                }
            }
        };

        return gulp.src('src/*.js')
            .pipe(handlebars(data, options))
            .pipe(gulp.dest('dist/'))
    }).catch((err) => {

        throw err;
    });
});

gulp.task('minify', ['build'], (cb) => {
    const uglifyOpts = {
        preserveComments: 'license'
    };

    /**
     * gulp-uglify recommends the use of the `pump` module
     * for better error reporting
     *
     * https://github.com/terinjokes/gulp-uglify/tree/master/docs/why-use-pump
     */
    pump([
        gulp.src('dist/*[!.min].js'),
        uglify(uglifyOpts),
        rename({suffix: '.min'}),
        gulp.dest('dist/')
    ], cb);
});

gulp.task('watch', () => {
    gulp.watch('src/*.js', ['build', 'minify'])
});

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


<commit_before>var babelify = require("babelify"),
  browserify = require("browserify"),
  cleanhtml = require("gulp-cleanhtml"),
  concat = require("gulp-concat"),
  del = require("del"),
  eslint = require("gulp-eslint"),
  globby = require("globby"),
  gulp = require("gulp"),
  gutil = require("gulp-util"),
  karma = require("karma"),
  merge = require("merge-stream"),
  cleanCSS = require("gulp-clean-css"),
  nunjucksGulp = require("./util/nunjucks-gulp"),
  rename = require("gulp-rename"),
  source = require("vinyl-source-stream"),
  uglify = require("gulp-uglify");

var srcDir = "src/";

var config = {
  appFile: "app.js",
  buildDir: "build/",
  distDir: "dist/",
  srcDir: srcDir
};

// Build all the things!
gulp.task("build", ["build:copy", "build:css", "build:html", "build:js"]);

// Clean build directory
gulp.task("build:clean", function() {
  return del(["build/*", "dist/*"]);
});

// Copy files that don't require any build process
gulp.task("build:copy", function() {
  gulp.src(["src/images/*"]).
    pipe(gulp.dest("build/images"));
  return gulp.src(["src/static/*"]).
    pipe(gulp.dest("build/static"));
});

// Build CSS
gulp.task("build:css", function() {
  return gulp.src("src/css/entries/*.css").
    pipe(cleanCSS({
      keepSpecialComments: 0,
      relativeTo: "",
      root: "",
    })).
    pipe(gulp.dest("build/css"));
});

// Build extension!
gulp.task("build:dist", ["build:dist:copy", "build:dist:js"]);

gulp.task("build:dist:copy", ["build"], function() {
  return gulp.src(["build/**/*"]).
    pipe(gulp.dest("dist"));
});

gulp.task("build:dist:js", ["build:js", "build:dist:copy"], function() {
  del(["dist/js/*"]);

  return gulp.src(["build/js/**/*.js"]).
    pipe(uglify()).
    on('error', gutil.log).
    pipe(gulp.dest("dist/js"));
});

// Compile and compress HTML files
gulp.task("build:html", function() {
  return gulp.src(["src/html/**/*.html", "!src/html/templates/**/*"])
  .pipe(nunjucksGulp({
    templateDir: srcDir + "html/templates",
  }))
  .pipe(cleanhtml())
  .pipe(gulp.dest("build"));
});

// Build the browserify bundle including the app
gulp.task("build:js", ["lint"], function(done) {
  function basename(filePath) {
    var components = filePath.split(/\//);
    return components[components.length - 1];
  }

  function bundleEntry(entryFile) {
    var bundle = browserify({
      debug: true,
      entries: entryFile
    });

    return bundle.
      transform("babelify", { presets: ["es2015"] }).
      bundle().
      pipe(source(basename(entryFile))).
      on("error", function(err) {
        gutil.log(err);
        this.emit("end");
      }).
      pipe(gulp.dest(config.buildDir + "js"));
  }
  var entries = globby.sync([config.srcDir + "js/entries/*.js"]),
    bundles = [],
    i;

  for (var i = 0; i < entries.length; ++i) {
    bundles.push(bundleEntry(entries[i]));
  }

  return merge.apply(this, bundles).
    on("alldone", done);
});

// Lint JS
gulp.task("lint", function() {
  return gulp.src("src/js/**/*.js").
    pipe(eslint()).
    pipe(eslint.format());
});

// Test for the more vanilla, transpiled build product.
gulp.task("test", ["lint"], function(done) {
  var opts = {
    configFile: __dirname + "/config/karma/build.conf.js",
    singleRun: true
  };
  new karma.Server.start(opts, done);
});

// Test task for situations where more introspection is needed.
gulp.task("test:chrome", ["lint"], function(done) {
  var opts = {
    autoWatch: true,
    browsers: ["Chrome"],
    configFile: __dirname + "/config/karma/build.conf.js"
  };
  new karma.Server.start(opts, done);
});

// Watch files and run tasks on changes
gulp.task("watch", function() {
  paths = [
    "config/**/*.js",
    "gulpfile.js",
    "src/**/*.*",
    "test/**/*.js"
  ];
  gulp.watch(paths, ["build"]);
});

gulp.task("default", ["test"]);
<commit_msg>Fix CSS relative pathing<commit_after>var babelify = require("babelify"),
  browserify = require("browserify"),
  cleanhtml = require("gulp-cleanhtml"),
  concat = require("gulp-concat"),
  del = require("del"),
  eslint = require("gulp-eslint"),
  globby = require("globby"),
  gulp = require("gulp"),
  gutil = require("gulp-util"),
  karma = require("karma"),
  merge = require("merge-stream"),
  cleanCSS = require("gulp-clean-css"),
  nunjucksGulp = require("./util/nunjucks-gulp"),
  rename = require("gulp-rename"),
  source = require("vinyl-source-stream"),
  uglify = require("gulp-uglify");

var srcDir = "src/";

var config = {
  appFile: "app.js",
  buildDir: "build/",
  distDir: "dist/",
  srcDir: srcDir
};

// Build all the things!
gulp.task("build", ["build:copy", "build:css", "build:html", "build:js"]);

// Clean build directory
gulp.task("build:clean", function() {
  return del(["build/*", "dist/*"]);
});

// Copy files that don't require any build process
gulp.task("build:copy", function() {
  gulp.src(["src/images/*"]).
    pipe(gulp.dest("build/images"));
  return gulp.src(["src/static/*"]).
    pipe(gulp.dest("build/static"));
});

// Build CSS
gulp.task("build:css", function() {
  return gulp.src("src/css/entries/*.css").
    pipe(cleanCSS({
      keepSpecialComments: 0,
      relativeTo: "./",
      root: "",
    })).
    pipe(gulp.dest("build/css"));
});

// Build extension!
gulp.task("build:dist", ["build:dist:copy", "build:dist:js"]);

gulp.task("build:dist:copy", ["build"], function() {
  return gulp.src(["build/**/*"]).
    pipe(gulp.dest("dist"));
});

gulp.task("build:dist:js", ["build:js", "build:dist:copy"], function() {
  del(["dist/js/*"]);

  return gulp.src(["build/js/**/*.js"]).
    pipe(uglify()).
    on('error', gutil.log).
    pipe(gulp.dest("dist/js"));
});

// Compile and compress HTML files
gulp.task("build:html", function() {
  return gulp.src(["src/html/**/*.html", "!src/html/templates/**/*"])
  .pipe(nunjucksGulp({
    templateDir: srcDir + "html/templates",
  }))
  .pipe(cleanhtml())
  .pipe(gulp.dest("build"));
});

// Build the browserify bundle including the app
gulp.task("build:js", ["lint"], function(done) {
  function basename(filePath) {
    var components = filePath.split(/\//);
    return components[components.length - 1];
  }

  function bundleEntry(entryFile) {
    var bundle = browserify({
      debug: true,
      entries: entryFile
    });

    return bundle.
      transform("babelify", { presets: ["es2015"] }).
      bundle().
      pipe(source(basename(entryFile))).
      on("error", function(err) {
        gutil.log(err);
        this.emit("end");
      }).
      pipe(gulp.dest(config.buildDir + "js"));
  }
  var entries = globby.sync([config.srcDir + "js/entries/*.js"]),
    bundles = [],
    i;

  for (var i = 0; i < entries.length; ++i) {
    bundles.push(bundleEntry(entries[i]));
  }

  return merge.apply(this, bundles).
    on("alldone", done);
});

// Lint JS
gulp.task("lint", function() {
  return gulp.src("src/js/**/*.js").
    pipe(eslint()).
    pipe(eslint.format());
});

// Test for the more vanilla, transpiled build product.
gulp.task("test", ["lint"], function(done) {
  var opts = {
    configFile: __dirname + "/config/karma/build.conf.js",
    singleRun: true
  };
  new karma.Server.start(opts, done);
});

// Test task for situations where more introspection is needed.
gulp.task("test:chrome", ["lint"], function(done) {
  var opts = {
    autoWatch: true,
    browsers: ["Chrome"],
    configFile: __dirname + "/config/karma/build.conf.js"
  };
  new karma.Server.start(opts, done);
});

// Watch files and run tasks on changes
gulp.task("watch", function() {
  paths = [
    "config/**/*.js",
    "gulpfile.js",
    "src/**/*.*",
    "test/**/*.js"
  ];
  gulp.watch(paths, ["build"]);
});

gulp.task("default", ["test"]);
<|endoftext|>


<commit_before>'use strict'

var gulp = require('gulp')
var electron = require('electron-connect').server.create()

// gulp.task('default', ['serve'])

// gulp.task('serve', () => {
//   console.log('watching')

//   // Start browser process
//   electron.start()

//   // Reload renderer process
//   gulp.watch(['index.js', 'player.js', 'index.html', 'assets/css/*.css', 'modules/*.js'], electron.restart)

//   // Reload renderer process
//   // gulp.watch(['player.js', 'templates/index.tmpl'], electron.restart)
// })

gulp.task('serve', () => {
  electron.start()
  gulp.watch(['index.js', 'player.js', 'index.html', 'assets/css/*.css', 'modules/*.js']).on('change', function(event) {
      console.log(event.path);
      console.log(event.type);
      electron.restart
      // code to execute
  });
});
<commit_msg>Update gulp file<commit_after>'use strict'

var gulp = require('gulp')
var electron = require('electron-connect').server.create()

gulp.task('serve', () => {
  electron.start()
  gulp.watch(['index.js', 'player.js', 'index.html', 'assets/css/*.css', 'modules/*.js']).on('change', (event) => {
    electron.restart
  })
})
<|endoftext|>


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

const BUILD_DIR = './dist/';
const COVERAGE_DIR = 'coverage';

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

/**
 * Empties BUILD_DIR and all generated files
 */
gulp.task('clean', function(cb) {
	var del = require('del');
	del([BUILD_DIR + '*', COVERAGE_DIR], cb);
});

/**
 * Generates browser-ready version for API in BUILD_DIR
 * File will be named as api.js
 */
gulp.task('build', function() {
	var browserify = require('browserify');
	var source = require('vinyl-source-stream');
	return browserify(
			'./src/api.js',
			{
				standalone: 'Api'
			}
		)
		.bundle()
		.pipe(source('api.js'))
		.pipe(gulp.dest(BUILD_DIR));
});

gulp.task('serve', function() {
	var webserver = require('gulp-webserver');
	gulp.src('./')
		.pipe(webserver({
			hostname: 'localhost',
			port: 8000,
			livereload: true,
			directoryListing: true,
			open: true
		}));
});

var runMocha = function() {
	var mocha = require('gulp-mocha');
	return gulp.src('test/**/*Spec.js', {read: false})
		.pipe(mocha({}));
};

gulp.task('test', runMocha);

gulp.task('test-coverage', function(cb) {
	var mocha = require('gulp-mocha');
	var istanbul = require('gulp-istanbul');

	gulp.src(['src/**/*.js'])
		.pipe(istanbul()) // Covering files
		.pipe(istanbul.hookRequire()) // Force `require` to return covered files
		.on('finish', function () {
			runMocha()
			.pipe(istanbul.writeReports()) // Creating the reports after tests runned
			.on('end', cb);
		});
});

gulp.task('test-coveralls', function() {
	var coveralls = require('gulp-coveralls');
	return gulp.src(COVERAGE_DIR + '/lcov.info')
		.pipe(coveralls());
});

gulp.task('test-ci', ['clean', 'test-coverage', 'test-coveralls']);
<commit_msg>run test-ci tasks in sequence<commit_after>var gulp = require('gulp');

const BUILD_DIR = './dist/';
const COVERAGE_DIR = 'coverage';

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

/**
 * Empties BUILD_DIR
 */
gulp.task('clean', ['clean-coverage'], function(cb) {
	var del = require('del');
	del([BUILD_DIR + '*', COVERAGE_DIR], cb);
});

/**
 * Cleans coverage data
 */
gulp.task('clean-coverage', function(cb) {
	var del = require('del');
	del([COVERAGE_DIR], cb);
});

/**
 * Generates browser-ready version for API in BUILD_DIR
 * File will be named as api.js
 */
gulp.task('build', ['clean'], function() {
	var browserify = require('browserify');
	var source = require('vinyl-source-stream');
	return browserify(
			'./src/api.js',
			{
				standalone: 'Api'
			}
		)
		.bundle()
		.pipe(source('api.js'))
		.pipe(gulp.dest(BUILD_DIR));
});

gulp.task('serve', function() {
	var webserver = require('gulp-webserver');
	gulp.src('./')
		.pipe(webserver({
			hostname: 'localhost',
			port: 8000,
			livereload: true,
			directoryListing: true,
			open: true
		}));
});

var runMocha = function() {
	var mocha = require('gulp-mocha');
	return gulp.src('test/**/*Spec.js', {read: false})
		.pipe(mocha({}));
};

gulp.task('test', runMocha);

gulp.task('test-coverage', ['clean-coverage'], function(cb) {
	var mocha = require('gulp-mocha');
	var istanbul = require('gulp-istanbul');

	gulp.src(['src/**/*.js'])
		.pipe(istanbul()) // Covering files
		.pipe(istanbul.hookRequire()) // Force `require` to return covered files
		.on('finish', function () {
			runMocha()
			.pipe(istanbul.writeReports()) // Creating the reports after tests runned
			.on('end', cb);
		});
});

gulp.task('test-ci', ['test-coverage'], function() {
	var coveralls = require('gulp-coveralls');
	return gulp.src(COVERAGE_DIR + '/lcov.info')
		.pipe(coveralls());
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var browserify = require('browserify');
var del = require('del');
var reactify = require('reactify');
var transform = require('vinyl-transform');
var fs = require('fs');
var path = require('path');
var plugins = require('gulp-load-plugins')();
var gutil = require('gulp-util');

var config = { production: false };

// Scripts
var appDir = "./src/app/";
var appPath = appDir + "**/*.jsx";
var appBuildDir = "./build/js/";

var componentDir = "./src/component/"
var componentPaths = fs.readdirSync(componentDir);
var componentBuildDir = "./build/js/";

var vendorDir = "./build/js/";
var vendorFileName = "vendor.js";
var vendorModules = [
/*
    {
        bowerName: "showdown",
        devSource: "src/showdown.js",
        prodSource: "compressed/showdown.js",
    },
*/
];

// Styles
var stylesDir ='./src/styles/';
var stylesBuildDir = './build/css/';

var cssPath = stylesDir + '**/*.css';
var sassPath = stylesDir + '**/!(_)*.scss';

gulp.task('set-production', function(done){
    config.production = true;
    gutil.log("Produccion!");
    done();
});

gulp.task('clean-css', function(done){
    del(['build/css'], done);
});
gulp.task('clean-js', function(done){
    del(['build/js'], done);
})

gulp.task('clean-authors', function(done){
    del(['build/data/autor'], done);
})

gulp.task('clean-posts', function(done){
    del(['build/data/post'], done);
})

gulp.task('vendor', ['clean-js'], function(){
    var vendorPathList = vendorModules.map(function(item){
        var moduleName = config.production?item.prodSource:item.devSource;
        var modulePath = path.join("bower_components", item.bowerName ,moduleName);
        return modulePath
    });
    return gulp.src(vendorPathList, {base: "bower_components"})
        .pipe(plugins.concat(vendorFileName))
        .pipe(config.production ? plugins.uglify() : gutil.noop())
        .pipe(gulp.dest(vendorDir))
        .on('error', gutil.log);
});

gulp.task('browserify', ['clean-js', 'vendor'], function(){
    //Bundle apps
    var browserified = transform(function(filename){
        gutil.log('browserify',filename);
        var b = browserify(filename);
        //b.transform(reactify);

        return b.bundle();
    });
    return gulp.src(appPath)
        .pipe(browserified)
        .pipe(config.production ? plugins.uglify() : gutil.noop())
        .pipe(plugins.rename(function(filePath){ filePath.extname = ".js";}))
        .pipe(gulp.dest(appBuildDir));
});

gulp.task('css', ['clean-css'], function(){
    return gulp.src(cssPath)
        .pipe(gulp.dest(stylesBuildDir));
});
gulp.task('sass', ['clean-css'], function(){
    return gulp.src(sassPath)
        .pipe(plugins.sass({errLogToConsole: true}))
        .pipe(gulp.dest(stylesBuildDir));
});

gulp.task('styles', ['css', 'sass']);

// Produccion
gulp.task('deploy', ['set-production', 'default']);

// Por defecto, desarrollo
gulp.task('default', ['vendor', 'browserify', 'styles']);

gulp.task('watch', ['vendor', 'browserify', 'styles'], function(){
    gulp.watch('src/**/*.jsx', ['browserify']).on('change', function(event){
        gutil.log(event.type, event.path);
    });
    gulp.watch(cssPath, ['css']).on('change', function(event){
        gutil.log(event.type, event.path);
    });
    gulp.watch(sassPath, ['sass']).on('change', function(event){
        gutil.log(event.type, event.path);
    });
});
<commit_msg>Arreglado gulp watch para archivos sass que importan a otros<commit_after>var gulp = require('gulp');
var browserify = require('browserify');
var del = require('del');
var reactify = require('reactify');
var transform = require('vinyl-transform');
var fs = require('fs');
var path = require('path');
var plugins = require('gulp-load-plugins')();
var gutil = require('gulp-util');

var config = { production: false };

// Scripts
var appDir = "./src/app/";
var appPath = appDir + "**/*.jsx";
var appBuildDir = "./build/js/";

var componentDir = "./src/component/"
var componentPaths = fs.readdirSync(componentDir);
var componentBuildDir = "./build/js/";

var vendorDir = "./build/js/";
var vendorFileName = "vendor.js";
var vendorModules = [
/*
    {
        bowerName: "showdown",
        devSource: "src/showdown.js",
        prodSource: "compressed/showdown.js",
    },
*/
];

// Styles
var stylesDir ='./src/styles/';
var stylesBuildDir = './build/css/';

var cssPath = stylesDir + '**/*.css';
var sassPath = stylesDir + '**/!(_)*.scss';
var sassFiles = stylesDir + '**/*.scss';

gulp.task('set-production', function(done){
    config.production = true;
    gutil.log("Produccion!");
    done();
});

gulp.task('clean-css', function(done){
    del(['build/css'], done);
});
gulp.task('clean-js', function(done){
    del(['build/js'], done);
})

gulp.task('clean-authors', function(done){
    del(['build/data/autor'], done);
})

gulp.task('clean-posts', function(done){
    del(['build/data/post'], done);
})

gulp.task('vendor', ['clean-js'], function(){
    var vendorPathList = vendorModules.map(function(item){
        var moduleName = config.production?item.prodSource:item.devSource;
        var modulePath = path.join("bower_components", item.bowerName ,moduleName);
        return modulePath
    });
    return gulp.src(vendorPathList, {base: "bower_components"})
        .pipe(plugins.concat(vendorFileName))
        .pipe(config.production ? plugins.uglify() : gutil.noop())
        .pipe(gulp.dest(vendorDir))
        .on('error', gutil.log);
});

gulp.task('browserify', ['clean-js', 'vendor'], function(){
    //Bundle apps
    var browserified = transform(function(filename){
        gutil.log('browserify',filename);
        var b = browserify(filename);
        //b.transform(reactify);

        return b.bundle();
    });
    return gulp.src(appPath)
        .pipe(browserified)
        .pipe(config.production ? plugins.uglify() : gutil.noop())
        .pipe(plugins.rename(function(filePath){ filePath.extname = ".js";}))
        .pipe(gulp.dest(appBuildDir));
});

gulp.task('css', ['clean-css'], function(){
    return gulp.src(cssPath)
        .pipe(gulp.dest(stylesBuildDir));
});
gulp.task('sass', ['clean-css'], function(){
    return gulp.src(sassPath)
        .pipe(plugins.sass({errLogToConsole: true}))
        .pipe(gulp.dest(stylesBuildDir));
});

gulp.task('styles', ['css', 'sass']);

// Produccion
gulp.task('deploy', ['set-production', 'default']);

// Por defecto, desarrollo
gulp.task('default', ['vendor', 'browserify', 'styles']);

gulp.task('watch', ['vendor', 'browserify', 'styles'], function(){
    gulp.watch('src/**/*.jsx', ['browserify']).on('change', function(event){
        gutil.log(event.type, event.path);
    });
    gulp.watch(cssPath, ['css']).on('change', function(event){
        gutil.log(event.type, event.path);
    });
    gulp.watch(sassFiles, ['sass']).on('change', function(event){
        gutil.log(event.type, event.path);
    });
});
<|endoftext|>


<commit_before>var gulp = require('gulp')
var vuize = require('./lib/index')
var gulpif = require('gulp-if')
var stylus = require('gulp-stylus')
var path = require('path')

var isStylus = function(file) {
  return path.extname(file.path) == 'styl'
}

gulp.task('default', function() {
  gulp.src('./*.+(js|styl|html)')
    .pipe(gulpif(isStylus, stylus()))
    .pipe(vuize())
    .pipe(gulp.dest('./'))
})

<commit_msg>Remove gulpfile.js (it was made for debugging)<commit_after><|endoftext|>


<commit_before>var gulp = require("gulp");
var sass = require("gulp-sass");
var nano = require("gulp-cssnano");
var sourcemaps = require("gulp-sourcemaps");

/*
 Build civil.css
 */
gulp.task("build", function () {
    gulp.src("./sass/**/*.scss")
        .pipe(sourcemaps.init())
        .pipe(sass({
            //outputStyle: "compressed",
            includePaths: ["./bower_components/bourbon/app/assets/stylesheets/"]
        }))
        .pipe(nano())
        .pipe(sourcemaps.write("."))
        .pipe(gulp.dest("./dist"));
});

gulp.task("build:watch", ["build"], function () {
    gulp.watch("./sass/**/*.scss", ["build"]);
});

/*
 Build docs
 */
gulp.task("build:docs", ["copy:docs"], function () {
    gulp.src("./docs/sass/**/*.scss")
        .pipe(sourcemaps.init())
        .pipe(sass({
            //outputStyle: "compressed",
            includePaths: [
                "./bower_components/bourbon/app/assets/stylesheets",
                "./sass"]
        }))
        .pipe(nano())
        .pipe(sourcemaps.write("."))
        .pipe(gulp.dest("./docs/css"));
});

gulp.task("build:docs:watch", ["build:docs"], function () {
    gulp.watch("./docs/sass/**/*.scss", ["build:docs"]);
});

/*
 Copy civil.css latest build for docs
 */
gulp.task("copy:docs", function () {
    gulp.src(["./dist/civil.css", "./dist/syntax.css"])
        .pipe(gulp.dest("./docs/css"));

    gulp.src("dist/civil.js")
        .pipe(gulp.dest("./docs/js"));
});

gulp.task("default", ["src", "docs"]);
gulp.task("src", ["build"]);
gulp.task("docs", ["build:docs"]);<commit_msg>Add dev task to watch both src, and docs<commit_after>var gulp = require("gulp");
var sass = require("gulp-sass");
var nano = require("gulp-cssnano");
var sourcemaps = require("gulp-sourcemaps");

/*
 Build civil.css
 */
gulp.task("build", function () {
    gulp.src("./sass/**/*.scss")
        .pipe(sourcemaps.init())
        .pipe(sass({
            //outputStyle: "compressed",
            includePaths: ["./bower_components/bourbon/app/assets/stylesheets/"]
        }))
        .pipe(nano())
        .pipe(sourcemaps.write("."))
        .pipe(gulp.dest("./dist"));
});

gulp.task("build:watch", ["build"], function () {
    gulp.watch("./sass/**/*.scss", ["build"]);
});

/*
 Build docs
 */
gulp.task("build:docs", function () {
    gulp.src("./docs/sass/**/*.scss")
        .pipe(sourcemaps.init())
        .pipe(sass({
            //outputStyle: "compressed",
            includePaths: [
                "./bower_components/bourbon/app/assets/stylesheets",
                "./sass"]
        }))
        .pipe(nano())
        .pipe(sourcemaps.write("."))
        .pipe(gulp.dest("./docs/css"));
});

gulp.task("build:docs:watch", ["build:docs"], function () {
    gulp.watch("./docs/sass/**/*.scss", ["build:docs"]);
});

/*
 Copy civil.css latest build for docs
 */
gulp.task("copy:docs", function () {
    gulp.src(["./dist/civil.css", "./dist/syntax.css"])
        .pipe(gulp.dest("./docs/css"));

    gulp.src("dist/civil.js")
        .pipe(gulp.dest("./docs/js"));
});

/*
 Watch src and docs
 */
gulp.task("dev", function () {
    gulp.watch("./sass/**/*.scss", ["build"]);
    gulp.watch("./docs/sass/**/*.scss", ["docs"]);
});

gulp.task("default", ["src", "docs"]);
gulp.task("src", ["build"]);
gulp.task("docs", ["copy:docs", "build:docs"]);<|endoftext|>


<commit_before>var gulp = require('gulp'),
    config = require('./config');
    $ = require('gulp-load-plugins')({
        pattern: ['gulp-*', 'gulp.*'],
        replaceString: /\bgulp[\-.]/
    });

$.browser = require('browser-sync');

var DIRECTORIES = ['pc','sp','admin'];
var BASE_TYPE = getBaseType();
var BASE_PATH = getBasePath();
var MINIFY = process.argv.indexOf('-min') === -1 ? false : true;

function getBasePath() {
    var path = config.APP_PATH;
    if (!config.flatten) {
        path += '/' + BASE_TYPE;
    }
    return path;
}

function getBaseType() {
    var type = '';
    if (!config.flatten) {
        for (var i = 0, len = DIRECTORIES.length; i < len; i++) {
            if (process.argv.indexOf('-' + DIRECTORIES[i]) !== -1) {
                type = DIRECTORIES[i];
                break;
            }
        }
        if (!type) {
            type = DIRECTORIES[0];
        }
    }
    return type;
}

/**
 * パス生成関数
 * @param name
 * @param prop
 * @returns {string}
 */
function getPath(name,prop) {
    prop = prop || 'src';
    var path = config.path[name][prop];
    if (typeof path === 'object') {
        return path.map(function(val) {
            if (val.charAt(0) === '!') {
                return '!' + BASE_PATH + '/' + val.substring(1);
            }
            return BASE_PATH + '/' + val;
        })
    } else {
        path = path || '';
        return BASE_PATH + '/' + path;
    }
}

// globalに共通変数書き出し
global.frontplate = {
    plugins: $,
    config: config,
    getPath: getPath,
    BASE_TYPE: BASE_TYPE,
    BASE_PATH: BASE_PATH,
    MINIFY: MINIFY
};

gulp.task('watch', function() {
    gulp.watch(getPath('js'), ['jshint']);
    gulp.watch(getPath('ejs','watch'), ['ejs']);
    gulp.watch(getPath('iconfont'), ['iconfont','style']);
    gulp.watch(getPath('sass'), ['style']);
    gulp.watch(getPath('html'), ['htmllint']);
    gulp.watch(getPath('sprite','watch'), ['sprite']);
    gulp.watch(getPath('images'), ['imagemin']);
});

// gulpディレクトリのタスク読み込み
var tasks = require('./gulp/load');
gulp.task('build',['ejs','iconfont','style','sprite','imagemin'], function() {});
gulp.task('default',['server','watch','watchScript'], function() {});<commit_msg>ディレクトリを自由に設定できるようにオプション設定できるように<commit_after>var gulp = require('gulp'),
    config = require('./config');
    $ = require('gulp-load-plugins')({
        pattern: ['gulp-*', 'gulp.*'],
        replaceString: /\bgulp[\-.]/
    });

var runSequence = require('run-sequence');
var extend = require('extend');
$.browser = require('browser-sync');

var DEFAULT_OPTIONS = {
    min: false,
    d: config.defaultDir || ''
};
var APP_PATH = config.appPath;
var OPTIONS = parseOption(process.argv);
function parseOption(argv) {
    var options = extend({},DEFAULT_OPTIONS);
    for(var i = 0, len = argv.length; i < len; i++) {
        if (argv[i].charAt(0) === '-') {
            var match = argv[i].substring(1).split('=');
            var key = match[0];
            var value = match[1] || true;
            options[key] = value;
        }
    }
    return options;
}

/**
 * パス生成関数
 * @param name
 * @param prop
 * @returns {string}
 */
function getPath(name, prop) {
    prop = prop || 'src';
    if (!config.path[name] || !config.path[name][prop]) {
        return console.log('[ERROR] not found path - ' + name + '.' + prop);
    }
    var path = config.path[name][prop];
    if (typeof path === 'object') {
        return path.map(function (val) {
            if (val.charAt(0) === '!') {
                return '!' + APP_PATH + '/' + replaceTypeTag(val.substring(1));
            }
            return APP_PATH + '/' + replaceTypeTag(val);
        });
    } else {
        path = path || '';
        return APP_PATH + '/' + replaceTypeTag(path);
    }
}
function replaceTypeTag(val) {
    if (OPTIONS.d) {
        return val.replace(/%type%/g, OPTIONS.d);
    }
    return val.replace(/\/%type%/g, '');
}

// globalに共通変数書き出し
global.frontplate = {
    plugins: $,
    config: config,
    getPath: getPath,
    option: OPTIONS
};

gulp.task('watch', function() {
    gulp.watch(getPath('ejs','watch'), ['ejs']);
    gulp.watch(getPath('sass'), ['style']);
    gulp.watch(getPath('sprite','watch'), ['sprite']);
    gulp.watch(getPath('images'), ['imagemin']);
});

// gulpディレクトリのタスク読み込み
var tasks = require('./gulp/load');
gulp.task('build',['clean'], function(callback) {
    return runSequence(['ejs', 'style', 'imagemin', 'script'], callback);
});
gulp.task('default',['server','watch','watchScript'], function() {});<|endoftext|>


<commit_before>const gulp = require('gulp')
      , gulpLoadPlugins = require('gulp-load-plugins')
      , path = require('path')
      , del = require('del')
      , runSequence = require('run-sequence')
      , deploy = require('gulp-deploy-git');

const plugins = gulpLoadPlugins();

const paths = {
  js: ['./**/*.js', '!dist/**', '!node_modules/**'],
  nonJs: ['./package.json', './.gitignore', './gulpfile.js'],
  filesToBuild: ['Procfile']
};

gulp.task('clean', () =>
  del(['**/*', '!dist/**', '!Procfile', '!gulpfile.js', '!package.json'])
);

gulp.task('copy', () =>
  gulp.src(paths.nonJs)
    .pipe(plugins.newer('dist'))
    .pipe(gulp.dest('dist'))
);

gulp.task('copyToBuild', () =>
  gulp.src(paths.filesToBuild)
    .pipe(plugins.newer('dist'))
    .pipe(gulp.dest('dist'))
);

gulp.task('babel', () =>
  gulp.src(['./**/*.js', '!dist/**', '!node_modules/**', '!gulpfile.js'], { base: '.' })
    .pipe(plugins.newer('dist'))
    .pipe(plugins.sourcemaps.init())
    .pipe(plugins.babel())
    .pipe(plugins.sourcemaps.write('.', {
      includeContent: false,
      sourceRoot(file) {
        return path.relative(file.path, __dirname);
      }
    }))
    .pipe(gulp.dest('dist'))
);

gulp.task('nodemon', ['copy', 'babel'], () =>
  plugins.nodemon({
    script: path.join('dist', 'index.js'),
    ext: 'js',
    ignore: ['node_modules/**/*.js', 'dist/**/*.js'],
    tasks: ['copy', 'babel']
  })
);

gulp.task('serve', ['clean'], () => runSequence('nodemon'));

gulp.task('default', ['clean'], () => {
  runSequence(['copy', 'babel']);
});

gulp.task('deploy', () => {
  gulp.src('dist', { read: false })
    .pipe(deploy({
      repository: 'https://github.com/guuibayer/Notificat.git',
      branches: ['develop'],
      remoteBranch: ['master']
    }));
});

gulp.task('build', ['babel', 'deploy']);
<commit_msg>Small changes in gulp task<commit_after>const gulp = require('gulp')
      , gulpLoadPlugins = require('gulp-load-plugins')
      , path = require('path')
      , del = require('del')
      , runSequence = require('run-sequence')
      , deploy = require('gulp-deploy-git');

const plugins = gulpLoadPlugins();

const paths = {
  js: ['./**/*.js', '!dist/**', '!node_modules/**'],
  nonJs: ['./package.json', './.gitignore', './gulpfile.js'],
  filesToBuild: ['Procfile']
};

gulp.task('clean', () =>
  del(['**/*', '!dist/**', '!Procfile', '!gulpfile.js', '!package.json'])
);

gulp.task('copy', () =>
  gulp.src(paths.nonJs)
    .pipe(plugins.newer('dist'))
    .pipe(gulp.dest('dist'))
);

gulp.task('copyToBuild', () =>
  gulp.src(paths.filesToBuild)
    .pipe(plugins.newer('dist'))
    .pipe(gulp.dest('dist'))
);

gulp.task('babel', () =>
  gulp.src(['./**/*.js', '!dist/**', '!node_modules/**', '!gulpfile.js'], { base: '.' })
    .pipe(plugins.newer('dist'))
    .pipe(plugins.sourcemaps.init())
    .pipe(plugins.babel())
    .pipe(plugins.sourcemaps.write('.', {
      includeContent: false,
      sourceRoot(file) {
        return path.relative(file.path, __dirname);
      }
    }))
    .pipe(gulp.dest('dist'))
);

gulp.task('nodemon', ['copy', 'babel'], () =>
  plugins.nodemon({
    script: path.join('dist', 'index.js'),
    ext: 'js',
    ignore: ['node_modules/**/*.js', 'dist/**/*.js'],
    tasks: ['copy', 'babel']
  })
);

gulp.task('serve', ['clean'], () => runSequence('nodemon'));

gulp.task('default', ['clean'], () => {
  runSequence(['copy', 'babel']);
});

gulp.task('deploy', () => {
  gulp.src('dist', { read: false })
    .pipe(deploy({
      repository: 'https://github.com/guuibayer/Notificat.git',
      branches: ['develop'],
      remoteBranch: ['master'],
      debug: true
    }));
});

gulp.task('build', ['babel', 'deploy']);
<|endoftext|>


<commit_before>var gulp=require("gulp");
var uglify=require("gulp-uglify");
var rename = require('gulp-rename');
var del = require('del');

var git = require('gulp-git');
var bump = require('gulp-bump');
var filter = require('gulp-filter');
var tag_version = require('gulp-tag-version');

var browserSync = require('browser-sync');
var reload = browserSync.reload;

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

var BROWSERSYNC_PORT = parseInt(process.env.PORT) || 3002;
var BROWSERSYNC_HOST = process.env.IP || "127.0.0.1";

gulp.task("compress",  function() {
  gulp.src("src/*.js")
    .pipe(uglify())
    .pipe(rename({ suffix: '.min' }))
    .pipe(gulp.dest("dist"));
});

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

gulp.task("default", ["compress"]);

function inc(importance) {
  // get all the files to bump version in
  return gulp.src(['./package.json', './bower.json'])
    // bump the version number in those files
    .pipe(bump({ type: importance }))
    // save it back to filesystem
    .pipe(gulp.dest('./'))
    // commit the changed version number
    .pipe(git.commit('bumps package version'))
    // read only one file to get the version number
    .pipe(filter('package.json'))
    // **tag it in the repository**
    .pipe(tag_version());
}

// these tasks are called from scripts/release.js
gulp.task('bump-patch', ["compress"], function () { return inc('patch'); });
gulp.task('bump-minor', ["compress"], function () { return inc('minor'); });
gulp.task('bump-major', ["compress"], function () { return inc('major'); });

gulp.task('reload', reload);

gulp.task('serve', ['default'], function () {
  browserSync({
    port: BROWSERSYNC_PORT,
    host: BROWSERSYNC_HOST,
    notify: false,
    server: '.'
  });

  gulp.watch('./src/**/*', ['compress', 'reload']);
  gulp.watch('./examples/**/*', ['reload']);
  gulp.watch('./browser-tests/**/*', ['reload']);
});
<commit_msg>left-over<commit_after>var gulp=require("gulp");
var uglify=require("gulp-uglify");
var rename = require('gulp-rename');
var del = require('del');

var git = require('gulp-git');
var bump = require('gulp-bump');
var filter = require('gulp-filter');
var tag_version = require('gulp-tag-version');

var browserSync = require('browser-sync');
var reload = browserSync.reload;

var BROWSERSYNC_PORT = parseInt(process.env.PORT) || 3002;
var BROWSERSYNC_HOST = process.env.IP || "127.0.0.1";

gulp.task("compress",  function() {
  gulp.src("src/*.js")
    .pipe(uglify())
    .pipe(rename({ suffix: '.min' }))
    .pipe(gulp.dest("dist"));
});

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

gulp.task("default", ["compress"]);

function inc(importance) {
  // get all the files to bump version in
  return gulp.src(['./package.json', './bower.json'])
    // bump the version number in those files
    .pipe(bump({ type: importance }))
    // save it back to filesystem
    .pipe(gulp.dest('./'))
    // commit the changed version number
    .pipe(git.commit('bumps package version'))
    // read only one file to get the version number
    .pipe(filter('package.json'))
    // **tag it in the repository**
    .pipe(tag_version());
}

// these tasks are called from scripts/release.js
gulp.task('bump-patch', ["compress"], function () { return inc('patch'); });
gulp.task('bump-minor', ["compress"], function () { return inc('minor'); });
gulp.task('bump-major', ["compress"], function () { return inc('major'); });

gulp.task('reload', reload);

gulp.task('serve', ['default'], function () {
  browserSync({
    port: BROWSERSYNC_PORT,
    host: BROWSERSYNC_HOST,
    notify: false,
    server: '.'
  });

  gulp.watch('./src/**/*', ['compress', 'reload']);
  gulp.watch('./examples/**/*', ['reload']);
  gulp.watch('./browser-tests/**/*', ['reload']);
});
<|endoftext|>


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

var gutil   = require('gulp-util');
var notify  = require('gulp-notify');
var del     = require('del');
var sourcemaps = require("gulp-sourcemaps");
var source  = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var globby = require('globby');
var rename  = require('gulp-rename');
var es      = require('event-stream');

var jade    = require('gulp-jade');
var sass    = require('gulp-sass');
var cleanCSS = require('gulp-clean-css');

var jshint  = require('gulp-jshint');
var browserify = require('browserify');
var uglify  = require('gulp-uglify');

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

// - - - - - VARIABLES - - - - - //
var reload  = browserSync.reload;
var SRC = './src';
var DIST = './dist';
var TEST = './test';

// - - - - - HELPERS - - - - - //
//SOURCE: mlouro/gulpfile.js - https://gist.github.com/mlouro/8886076
var handleError = function(task) {
  return function(err) {

      notify.onError({
        message: task + ' failed, check the logs..'
      })(err);

    gutil.log(gutil.colors.bgRed(task + ' error:'), gutil.colors.red(err));
  };
};

// - - - - - TASKS - - - - - //
gulp.task('clean', function(callback) {
    del([TEST + '/**', DIST + '/**']).then(function() {
        callback();
    });
});

// Perform a direct copy of all assets;
// excluding anything to be handled by other tasks...
gulp.task('assets', function() {
  return gulp.src([SRC + '/**/*',
                    '!' + SRC + '/**/_lib',
                    '!' + SRC + '/**/*.js',
                    '!' + SRC + '/**/*.scss',
                    '!' + SRC + '/**/_templates',
                    '!' + SRC + '/**/*.jade'])
  .pipe(gulp.dest(TEST))
  .pipe(browserSync.stream());
});

gulp.task('lint', function() {
    return gulp.src([SRC + '/**/*.js',
                    //exclude JS files handled by browserify
                    '!' + SRC + '/**/_lib',
                    '!' + SRC + '/**/main_**.js',
                    '!' + SRC + '/**/_*.js'])
        .pipe(jshint())
        .pipe(jshint.reporter('jshint-stylish'))
        .pipe(gulp.dest(TEST))
        .pipe(browserSync.stream());
})

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

  globby([SRC + '/**/main_**.js']).then(function(entries) {

      var tasks = entries.map(function(entry) {

          var entryAsString = String(entry);
          var filename = entryAsString.substring((entryAsString.indexOf('main_') + 5), (entryAsString.length-3));

        return browserify({
          entries: entry,
          debug: true,
          // for standalone to work you need to feed it
          // the desired (unique!) global identifier
          standalone: filename
        })
        .bundle()
        .on('error', handleError('browserify'))
        .pipe(source(entry))
        .pipe(rename(function(path) {
            // TODO: replacing pathname like this seems crude - particularly
            // since it doesn't use the SRC variable
            path.dirname = path.dirname.replace('src/', '');
            path.basename = path.basename.replace('main_', '');
        }))
        .pipe(buffer())
        .pipe(sourcemaps.init({loadMaps: true}))
          // Add gulp plugins to the pipeline here.
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest(TEST))
        .pipe(browserSync.stream());

    });

    es.merge(tasks)
    .on('update', reload)
    .on('end', done);

  }).catch(function(err) {
    handleError('browserify')
  });

});

// Note that any final build process relies on content of /TEST being up-to-date
gulp.task('uglify', ['browserify'], function() {
  return gulp.src(TEST + '/**/*.js')
    .pipe(uglify({output: {comments: /^!|@preserve|@license|@cc_on/i}}))
    .pipe(rename(function(path) {
        path.basename = path.basename += '.min';
    }))
    .pipe(gulp.dest(DIST));
});

// using templates will make it easier to ensure consistency
// and for example to globally update paths to dependencies hosted on CDN servers
// ...but you can author in plain old HTML if you so wish: the assets task will
// shunt html pages across to dist
gulp.task('templates', function() {
    //TODO: avoid processing pages that haven't changed
    return gulp.src(['./src/**/*.jade', '!./src/_templates/**' ])
        .pipe(jade({
            pretty: true,
            basedir: './tests/_templates'
        }))
        //TODO: fix this: reports errors, but doesn't allow watch task to continue
        .on('error', handleError('jade'))
        .pipe(gulp.dest(TEST))
        .pipe(browserSync.stream());
});

gulp.task('jade-watch', ['templates'], reload);

// As with HTML you could choose to author CSS directly; but SASS rocks :)
gulp.task('sass', function() {

  return gulp.src(SRC + '/**/*.scss')
    .pipe(sourcemaps.init())
    .pipe(sass({
        // outputStyle: 'compressed',
        //includePaths : ['./_vendor']
    }).on('error', sass.logError))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest(TEST))
    .pipe(browserSync.stream());

});

gulp.task('minify-css', function() {
  return gulp.src(TEST + '/**/*.css')
    .pipe(cleanCSS({compatibility: 'ie9'}))
    .pipe(rename(function(path) {
        path.basename += '.min';
    }))
    .pipe(gulp.dest(DIST));
});

// gulp.task('build', ['uglify', 'minify-css']);

// before serving content ensure it's all been built by running all tasks as devDependencies
//TODO: run clean first
gulp.task('serve',
         ['assets', 'templates', 'sass', 'lint', 'browserify'],
         function() {

          browserSync.init({
            server: {
              baseDir: TEST,
              directory: true // displays navigable directory structure
            },
            ghostmode: {
              clicks: true,
              forms: true,
              scroll: true
            }

          });

          gulp.watch(SRC + "/**/*.html", ['assets']);
          gulp.watch(SRC + "/**/*.css", ['assets']);
          gulp.watch(SRC + "/**/*.jade",  ['jade-watch']);
          gulp.watch(SRC + "/**/*.scss", ['sass']);
          gulp.watch(SRC + "/**/*.js", ['lint']);
          gulp.watch(SRC + "/**/*.js", ['browserify']);

});

gulp.task('default', ['serve']);
<commit_msg>now works when no browserify scripts are present<commit_after>// - - - - - DEPENDENCIES - - - - - //
var gulp = require('gulp');

var gutil = require('gulp-util');
var notify = require('gulp-notify');
var del = require('del');
var sourcemaps = require("gulp-sourcemaps");
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var globby = require('globby');
var rename = require('gulp-rename');
var es = require('event-stream');

var jade = require('gulp-jade');
var sass = require('gulp-sass');
var cleanCSS = require('gulp-clean-css');

var jshint = require('gulp-jshint');
var browserify = require('browserify');
var uglify = require('gulp-uglify');

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

// - - - - - VARIABLES - - - - - //
var reload = browserSync.reload;
var SRC = './src';
var DIST = './dist';
var TEST = './test';

// - - - - - HELPERS - - - - - //
//SOURCE: mlouro/gulpfile.js - https://gist.github.com/mlouro/8886076
var handleError = function(task) {
    return function(err) {

        notify.onError({
            message: task + ' failed, check the logs..'
        })(err);

        gutil.log(gutil.colors.bgRed(task + ' error:'), gutil.colors.red(err));
    };
};

// - - - - - TASKS - - - - - //
gulp.task('clean', function(callback) {
    del([TEST + '/**', DIST + '/**']).then(function() {
        callback();
    });
});

// Perform a direct copy of all assets;
// excluding anything to be handled by other tasks...
gulp.task('assets', function() {
    return gulp.src([SRC + '/**/*',
            '!' + SRC + '/**/_lib',
            '!' + SRC + '/**/*.js',
            '!' + SRC + '/**/*.scss',
            '!' + SRC + '/**/_templates',
            '!' + SRC + '/**/*.jade'
        ])
        .pipe(gulp.dest(TEST))
        .pipe(browserSync.stream());
});

gulp.task('lint', function() {
    return gulp.src([SRC + '/**/*.js',
            //exclude JS files handled by browserify
            '!' + SRC + '/**/_lib',
            '!' + SRC + '/**/main_**.js',
            '!' + SRC + '/**/_*.js'
        ])
        .pipe(jshint())
        .pipe(jshint.reporter('jshint-stylish'))
        .pipe(gulp.dest(TEST))
        .pipe(browserSync.stream());
})

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

    globby([SRC + '/**/main_**.js']).then(function(entries) {

        // in case there is no browserfiable content yet...
        if (entries.length > 0) {
            var tasks = entries.map(function(entry) {

                var entryAsString = String(entry);
                var filename = entryAsString.substring((entryAsString.indexOf('main_') + 5), (entryAsString.length - 3));

                return browserify({
                        entries: entry,
                        debug: true,
                        // for standalone to work you need to feed it
                        // the desired (unique!) global identifier
                        standalone: filename
                    })
                    .bundle()
                    .on('error', handleError('browserify'))
                    .pipe(source(entry))
                    .pipe(rename(function(path) {
                        // TODO: replacing pathname like this seems crude - particularly
                        // since it doesn't use the SRC variable
                        path.dirname = path.dirname.replace('src/', '');
                        path.basename = path.basename.replace('main_', '');
                    }))
                    .pipe(buffer())
                    .pipe(sourcemaps.init({
                        loadMaps: true
                    }))
                    // Add gulp plugins to the pipeline here.
                    .pipe(sourcemaps.write('./'))
                    .pipe(gulp.dest(TEST))
                    .pipe(browserSync.stream());

            });

            es.merge(tasks)
                .on('update', reload)
                .on('end', done);
        } else {
            done();
        }

    }).catch(function(err) {
        handleError('browserify')
    });

});

// Note that any final build process relies on content of /TEST being up-to-date
gulp.task('uglify', ['browserify'], function() {
    return gulp.src(TEST + '/**/*.js')
        .pipe(uglify({
            output: {
                comments: /^!|@preserve|@license|@cc_on/i
            }
        }))
        .pipe(rename(function(path) {
            path.basename = path.basename += '.min';
        }))
        .pipe(gulp.dest(DIST));
});

// using templates will make it easier to ensure consistency
// and for example to globally update paths to dependencies hosted on CDN servers
// ...but you can author in plain old HTML if you so wish: the assets task will
// shunt html pages across to dist
gulp.task('templates', function() {
    //TODO: avoid processing pages that haven't changed
    return gulp.src(['./src/**/*.jade', '!./src/_templates/**'])
        .pipe(jade({
            pretty: true,
            basedir: './tests/_templates'
        }))
        //TODO: fix this: reports errors, but doesn't allow watch task to continue
        .on('error', handleError('jade'))
        .pipe(gulp.dest(TEST))
        .pipe(browserSync.stream());
});

gulp.task('jade-watch', ['templates'], reload);

// As with HTML you could choose to author CSS directly; but SASS rocks :)
gulp.task('sass', function() {

    return gulp.src(SRC + '/**/*.scss')
        .pipe(sourcemaps.init())
        .pipe(sass({
            // outputStyle: 'compressed',
            //includePaths : ['./_vendor']
        }).on('error', sass.logError))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(TEST))
        .pipe(browserSync.stream());

});

gulp.task('minify-css', function() {
    return gulp.src(TEST + '/**/*.css')
        .pipe(cleanCSS({
            compatibility: 'ie9'
        }))
        .pipe(rename(function(path) {
            path.basename += '.min';
        }))
        .pipe(gulp.dest(DIST));
});

// gulp.task('build', ['uglify', 'minify-css']);

// before serving content ensure it's all been built by running all tasks as devDependencies
//TODO: run clean first
gulp.task('serve', ['assets', 'templates', 'sass', 'lint', 'browserify'],
    function() {

        browserSync.init({
            server: {
                baseDir: TEST,
                directory: true // displays navigable directory structure
            },
            ghostmode: {
                clicks: true,
                forms: true,
                scroll: true
            }

        });

        gulp.watch(SRC + "/**/*.html", ['assets']);
        gulp.watch(SRC + "/**/*.css", ['assets']);
        gulp.watch(SRC + "/**/*.jade", ['jade-watch']);
        gulp.watch(SRC + "/**/*.scss", ['sass']);
        gulp.watch(SRC + "/**/*.js", ['lint']);
        gulp.watch(SRC + "/**/*.js", ['browserify']);

    });

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


<commit_before>var gulp            = require('gulp'),
    autoprefixer    = require('gulp-autoprefixer'),
    cleanCSS        = require('gulp-clean-css'),
    connect         = require('gulp-connect'),
    csslint         = require('gulp-csslint'),
    eslint          = require('gulp-eslint'),
    lintspaces      = require('gulp-lintspaces'),
    nightwatch      = require('gulp-nightwatch'),
    rename          = require('gulp-rename'),
    uglify          = require('gulp-uglify');

gulp.task('csslint', function() {
    return gulp.src('src/imagelightbox.css')
        .pipe(csslint('.csslintrc'))
        .pipe(csslint.formatter());
});

gulp.task('copy:css', gulp.series('csslint', function() {
    return gulp.src('src/imagelightbox.css')
        .pipe(gulp.dest('docs/stylesheets/'));
}));

gulp.task('minify:css', gulp.series('copy:css', function() {
    return gulp.src('src/imagelightbox.css')
        .pipe(autoprefixer({
            browsers: ['last 2 versions', 'ie >= 9', 'Firefox ESR', 'Android >= 2.3'],
            cascade: false
        }))
        .pipe(cleanCSS())
        .pipe(rename('imagelightbox.min.css'))
        .pipe(gulp.dest('dist/'));
}));

gulp.task('editorconfig', function() {
    return gulp.src('src/imagelightbox.js')
        .pipe(lintspaces({editorconfig: './.editorconfig'}))
        .pipe(lintspaces.reporter());
});

gulp.task('eslint', function() {
    return gulp.src('src/imagelightbox.js')
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(eslint.failAfterError());
});

gulp.task('copy:js',  gulp.series('editorconfig', 'eslint', function() {
    return gulp.src('src/imagelightbox.js')
        .pipe(gulp.dest('docs/javascripts/'));
}));

gulp.task('minify:js', gulp.series('copy:js', function() {
    return gulp.src('src/imagelightbox.js')
        .pipe(uglify())
        .pipe(rename('imagelightbox.min.js'))
        .pipe(gulp.dest('dist/'));
}));

gulp.task('build', gulp.parallel('minify:css', 'minify:js'));

gulp.task('watch', function(done) {
    gulp.watch(['docs/*.html','src/**/*'], gulp.series('build'));
    done();
});

gulp.task('serve', gulp.parallel('build', 'watch', function(done) {
    connect.server({
        livereload: true
    });
    done();
}));

gulp.task('night:js', gulp.series('serve', function() {
    return gulp.src('./gulpfile.js')
        .pipe(nightwatch({
            configFile: './nightwatch.json'
        }));
}));

gulp.task('default', gulp.series('build'));

gulp.task('dev', gulp.series('serve'));

gulp.task('test', gulp.series('night:js'));
<commit_msg>Disabled eslint in build<commit_after>var gulp            = require('gulp'),
    autoprefixer    = require('gulp-autoprefixer'),
    cleanCSS        = require('gulp-clean-css'),
    connect         = require('gulp-connect'),
    csslint         = require('gulp-csslint'),
    eslint          = require('gulp-eslint'),
    lintspaces      = require('gulp-lintspaces'),
    nightwatch      = require('gulp-nightwatch'),
    rename          = require('gulp-rename'),
    uglify          = require('gulp-uglify');

gulp.task('csslint', function() {
    return gulp.src('src/imagelightbox.css')
        .pipe(csslint('.csslintrc'))
        .pipe(csslint.formatter());
});

gulp.task('copy:css', gulp.series('csslint', function() {
    return gulp.src('src/imagelightbox.css')
        .pipe(gulp.dest('docs/stylesheets/'));
}));

gulp.task('minify:css', gulp.series('copy:css', function() {
    return gulp.src('src/imagelightbox.css')
        .pipe(autoprefixer({
            browsers: ['last 2 versions', 'ie >= 9', 'Firefox ESR', 'Android >= 2.3'],
            cascade: false
        }))
        .pipe(cleanCSS())
        .pipe(rename('imagelightbox.min.css'))
        .pipe(gulp.dest('dist/'));
}));

gulp.task('editorconfig', function() {
    return gulp.src('src/imagelightbox.js')
        .pipe(lintspaces({editorconfig: './.editorconfig'}))
        .pipe(lintspaces.reporter());
});

gulp.task('eslint', function() {
    return gulp.src('src/imagelightbox.js')
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(eslint.failAfterError());
});

gulp.task('copy:js',  gulp.series('editorconfig', function() {
    return gulp.src('src/imagelightbox.js')
        .pipe(gulp.dest('docs/javascripts/'));
}));

gulp.task('minify:js', gulp.series('copy:js', function() {
    return gulp.src('src/imagelightbox.js')
        .pipe(uglify())
        .pipe(rename('imagelightbox.min.js'))
        .pipe(gulp.dest('dist/'));
}));

gulp.task('build', gulp.parallel('minify:css', 'minify:js'));

gulp.task('watch', function(done) {
    gulp.watch(['docs/*.html','src/**/*'], gulp.series('build'));
    done();
});

gulp.task('serve', gulp.parallel('build', 'watch', function(done) {
    connect.server({
        livereload: true
    });
    done();
}));

gulp.task('night:js', gulp.series('serve', function() {
    return gulp.src('./gulpfile.js')
        .pipe(nightwatch({
            configFile: './nightwatch.json'
        }));
}));

gulp.task('default', gulp.series('build'));

gulp.task('dev', gulp.series('serve'));

gulp.task('test', gulp.series('night:js'));
<|endoftext|>


<commit_before>const gulp = require('gulp')
const ts = require('gulp-typescript')
const flatten = require('gulp-flatten')
const mocha = require('gulp-spawn-mocha');
const env = require('gulp-env');
const wait = require('gulp-wait')
var   Server = require('karma').Server;
var protractor = require("gulp-protractor").protractor;
const del = require('del');
const minimist = require('minimist');

var knownOptions = {
    string: ['env', 'hostname', 'port', 'mongo-path', 'node-inspector-port' ],
    boolean: ['debug', 'local-only' ],
    default: { env: process.env.NODE_ENV || 'production' }
};

var options = minimist(process.argv.slice(2), knownOptions);

////////////////////////////////////////////////////////////////////////////////
// all

// TODO: figure out how to pass boolean args without a value
//  e.g. gulp --debug test-server
//  consumes test-server, and issues error that default is undefined
gulp.task('help', () => {
    console.log('Options:')
    console.log('--env (development | qa | production)')
    console.log('    Sets server execution environment, defaults to development')
    console.log('--hostname hostname')
    console.log('    Sets the remote host, for automated tests using the network, defaults to localhost')
    console.log('--port port')
    console.log('    Sets the port for the server API, defaults to 80')
    console.log('--mongo-path path')
    console.log('    Sets the mongo database, for automated tests')
    console.log('--debug')
    console.log('    Runs mocha for the target in debug mode')
    console.log('--node-inspector-port port')
    console.log('    Sets the port for node-inspector')
    console.log('--local-only')
    console.log('    Runs the server in local-only mode, for automated tests without the network')
})

gulp.task('clean', () => {
    return del(['generated']);
})

gulp.task('build', ['build-client', 'build-server'])

gulp.task('test', ['test-client', 'test-server', 'test-end-to-end'])

////////////////////////////////////////////////////////////////////////////////
// server

gulp.task('build-server', function() {
  return gulp.src(['src/server/**/*.ts', 'src/shared/**/*.ts'])
    .pipe(ts({module: 'commonjs'})).js
    .pipe(flatten())
    .pipe(gulp.dest('./generated/commonjs'))
});

gulp.task('build-server-tests', function() {
  return gulp.src(['test/src/server/**/*.ts'])
    .pipe(ts({module: 'commonjs'})).js
    .pipe(flatten())
    .pipe(gulp.dest('./generated/commonjs'))
});

gulp.task('test-server', ['build-server', 'build-server-tests'], function() {
    //    how to set $(MOCHA_ARGS)
    var args = {
        reporter: 'spec',
        debugBrk: options.debug,
        env: {
            NODE_PATH: './generated/commonjs'
        }
    }
    return gulp.src('generated/commonjs/people-service.tests.js', {read: false})
        // gulp-mocha needs filepaths so you can't have any plugins before it
        .pipe(mocha(args));
});

gulp.task('clean-server', function() {
    return del(['generated/commonjs']);
});

////////////////////////////////////////////////////////////////////////////////
// client

gulp.task('build-client', function() {
  var tsProject = ts.createProject('src/client/tsconfig.json')
  return tsProject.src()
    .pipe(ts(tsProject)).js
    .pipe(flatten())
    .pipe(gulp.dest('./generated/amd'))
});

gulp.task('build-client-tests', function() {
  return gulp.src(['test/src/client/**/*.ts'])
    .pipe(ts({module: 'amd'})).js
    .pipe(flatten())
    .pipe(gulp.dest('./generated/amd'))
});

gulp.task('test-client', ['build-client', 'build-client-tests'], function(done) {
    new Server({
        configFile: __dirname + '/test/src/client/people-ng-service.karma.conf.js',
        singleRun: true
    }, done).start();
});

gulp.task('clean-client', () => {
    return del(['generated/amd', 'generated/system']);
});

////////////////////////////////////////////////////////////////////////////////
// end-to-end

gulp.task('build-end-to-end-tests', function() {
  return gulp.src(['test/end-to-end/**/*.ts'])
    .pipe(ts({module: 'commonjs'})).js
    .pipe(flatten())
    .pipe(gulp.dest('./generated/commonjs'))
});

gulp.task('test-end-to-end', ['build-client', 'build-server', 'build-end-to-end-tests'], function() {
    console.warn("WARNING: Assuming you have already run: webdriver-manager start")
    console.warn("WARNING: Assuming you have already run: bin/start-servers.sh --log --save")
    var stream = gulp.src(["./test/*.js"])
        .pipe(protractor({
            configFile: "test/end-to-end/protractor.conf.js",
            args: ['--framework', 'mocha']
        }))
        .on('error', function(e) { throw e })
    stream.on('end', function() {
        console.warn("WARNING: You must manually stop the servers: bin/stop-servers.sh")
    });
    return stream
});
<commit_msg>automated gulp test-end-to-end<commit_after>const gulp = require('gulp')
const ts = require('gulp-typescript')
const flatten = require('gulp-flatten')
const mocha = require('gulp-spawn-mocha');
const env = require('gulp-env');
const wait = require('gulp-wait')
var   Server = require('karma').Server;
var protractor = require("gulp-protractor").protractor;
const del = require('del');
const minimist = require('minimist');
const child_process = require('child_process');

var knownOptions = {
    string: ['env', 'hostname', 'port', 'mongo-path', 'node-inspector-port' ],
    boolean: ['debug', 'local-only' ],
    default: { env: process.env.NODE_ENV || 'production' }
};

var options = minimist(process.argv.slice(2), knownOptions);

// returns a Promise, resolving with the child process, or rejecting with an Error
function startProcess(options) {
    return new Promise(function(resolve, reject) {
        // DEBUG: console.log(`starting ${options.cmd} ${options.args}`)
        var child = child_process.spawn(options.cmd, options.args)
        child.on('error', (err) => {
            reject(err)
        });
        child.on('exit', (code, signal) => {
            // DEBUG: console.log(`exit ${options.cmd} ${options.args}: code=${code} signal=${signal}`)
        });
        var delay = options.delay || 0
        setTimeout(() => {
            resolve({child})
        }, delay)
    })
}

// returns a Promise, resolving with an array of the child processes, or rejecting with an Error
function startProcesses(processes) {
    var promises = []
    processes.forEach((process) => {
        promises.push(startProcess(process))
    })
    return Promise.all(promises)
}

// returns a Promise, resolving with the child process
function stopProcess(options) {
    return new Promise(function(resolve, reject) {
        // DEBUG: console.log(`stopping ${options.child.spawnargs}`)
        child_process.exec(`pgrep -P ${options.child.pid}`, (error, stdout, stderr) => {
            // DEBUG: console.log('child.kill(SIGINT)')
            options.child.kill('SIGINT')
            // DEBUG: console.log(`pgrep -P ${options.child.pid}  =>  ${stdout}`)
            var childs_children = stdout.trim().split(/\s/)
            childs_children.forEach((childs_child) => {
                // DEBUG: console.log(`kill -KILL ${childs_child}`)
                child_process.exec(`kill -KILL ${childs_child}`, (error, stdout, stderr) => {
                    if (error) {
                        reject(error)
                    }
                })
            })
            var delay = options.delay || 0
            setTimeout(() => {
                resolve()
            }, delay)
        })
    })
}

// returns a Promise, resolving with an array of the child processes
function stopProcesses(children) {
    var promises = []
    // DEBUG: console.log(`children=${children}`)
    children.forEach((child) => {
        promises.push(stopProcess(child))
    })
    return Promise.all(promises)
}

function runServers() {
    var processes = [
        // Cannot figure out how to programmatically shut down webdriver-manager
        // It seems it hangs gulp (due to child processes, other resources)?
        {cmd:'node_modules/gulp-protractor/node_modules/protractor/bin/webdriver-manager', args: ['start'], delay: 2000},
        // {cmd:'/usr/bin/vim', args: ['vim.tmp'], delay: 1000},
        // {cmd:'/usr/bin/vim', args: ['vim2.tmp'], delay: 1000}
        {cmd:'/usr/local/bin/node', args: ['src/server/js/people-pin-service.js'], delay: 1000},
        {cmd:'/usr/local/bin/node', args: ['src/server/js/people-app.js'], delay: 1000}
    ]
    return startProcesses(processes)
}

////////////////////////////////////////////////////////////////////////////////
// all

// TODO: figure out how to pass boolean args without a value
//  e.g. gulp --debug test-server
//  consumes test-server, and issues error that default is undefined
gulp.task('help', () => {
    console.log('Options:')
    console.log('--env (development | qa | production)')
    console.log('    Sets server execution environment, defaults to development')
    console.log('--hostname hostname')
    console.log('    Sets the remote host, for automated tests using the network, defaults to localhost')
    console.log('--port port')
    console.log('    Sets the port for the server API, defaults to 80')
    console.log('--mongo-path path')
    console.log('    Sets the mongo database, for automated tests')
    console.log('--debug')
    console.log('    Runs mocha for the target in debug mode')
    console.log('--node-inspector-port port')
    console.log('    Sets the port for node-inspector')
    console.log('--local-only')
    console.log('    Runs the server in local-only mode, for automated tests without the network')
})

gulp.task('clean', () => {
    return del(['generated']);
})

gulp.task('build', ['build-client', 'build-server'])

gulp.task('test', ['test-client', 'test-server', 'test-end-to-end'])

////////////////////////////////////////////////////////////////////////////////
// server

gulp.task('build-server', function() {
  return gulp.src(['src/server/**/*.ts', 'src/shared/**/*.ts'])
    .pipe(ts({module: 'commonjs'})).js
    .pipe(flatten())
    .pipe(gulp.dest('./generated/commonjs'))
});

gulp.task('build-server-tests', function() {
  return gulp.src(['test/src/server/**/*.ts'])
    .pipe(ts({module: 'commonjs'})).js
    .pipe(flatten())
    .pipe(gulp.dest('./generated/commonjs'))
});

gulp.task('test-server', ['build-server', 'build-server-tests'], function() {
    //    how to set $(MOCHA_ARGS)
    var args = {
        reporter: 'spec',
        debugBrk: options.debug,
        env: {
            NODE_PATH: './generated/commonjs'
        }
    }
    return gulp.src('generated/commonjs/people-service.tests.js', {read: false})
        // gulp-mocha needs filepaths so you can't have any plugins before it
        .pipe(mocha(args));
});

gulp.task('clean-server', function() {
    return del(['generated/commonjs']);
});

////////////////////////////////////////////////////////////////////////////////
// client

gulp.task('build-client', function() {
  var tsProject = ts.createProject('src/client/tsconfig.json')
  return tsProject.src()
    .pipe(ts(tsProject)).js
    .pipe(flatten())
    .pipe(gulp.dest('./generated/amd'))
});

gulp.task('build-client-tests', function() {
  return gulp.src(['test/src/client/**/*.ts'])
    .pipe(ts({module: 'amd'})).js
    .pipe(flatten())
    .pipe(gulp.dest('./generated/amd'))
});

gulp.task('test-client', ['build-client', 'build-client-tests'], function(done) {
    new Server({
        configFile: __dirname + '/test/src/client/people-ng-service.karma.conf.js',
        singleRun: true
    }, done).start();
});

gulp.task('clean-client', () => {
    return del(['generated/amd', 'generated/system']);
});

////////////////////////////////////////////////////////////////////////////////
// end-to-end

gulp.task('build-end-to-end-tests', function() {
  return gulp.src(['test/end-to-end/**/*.ts'])
    .pipe(ts({module: 'commonjs'})).js
    .pipe(flatten())
    .pipe(gulp.dest('./generated/commonjs'))
});

var test_end_to_end_promises
gulp.task('start-servers-for-end-to-end-tests', ['build-client', 'build-server', 'build-end-to-end-tests'], function() {
    test_end_to_end_promises = runServers()
    return test_end_to_end_promises
});

gulp.task('test-end-to-end', ['start-servers-for-end-to-end-tests'], function(done) {
    // TODO: set NODE_ENV=tests
    var stream = gulp.src(["./test/*.js"])
        .pipe(protractor({
            configFile: "test/end-to-end/protractor.conf.js",
            args: ['--framework', 'mocha']
        }))
        .on('error', function(e) { throw e })
    stream.on('end', function() {
        test_end_to_end_promises.then((children) => {
            stopProcesses(children).then(() => {
                // DEBUG: console.log('stopProcesses resolved')
                done()
            })
        })
    });
});
<|endoftext|>


<commit_before>const gulp = require('gulp');
const glob = require('glob');
const shell = cmd => require('child_process').execSync(cmd, { stdio: [0, 1, 2] });
const del = require('del');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const $ = require('gulp-load-plugins')();
const seq = require('run-sequence');
const browserify = require('browserify');
const watchify = require('watchify');
const tsify = require('tsify');
const minify = require('gulp-uglify/composer')(require('uglify-es'), console);
const Server = require('karma').Server;

const pkg = require('./package.json');
const config = {
  browsers: ['Chrome', 'Firefox'].concat((os => {
    switch (os) {
      case 'Windows_NT':
        return ['Edge'];
      case 'Darwin':
        return [];
     default:
        return [];
    }
  })(require('os').type())),
  ts: {
    dist: {
      src: [
        '*.ts'
      ],
      dest: 'dist'
    },
    test: {
      src: [
        '*.ts',
        'src/**/*.ts',
        'test/**/*.ts'
      ],
      dest: 'dist'
    }
  },
  banner: [
    `/*! ${pkg.name} v${pkg.version} ${pkg.repository.url} | (c) 2012, ${pkg.author} | ${pkg.license} License */`,
    ''
  ].join('\n'),
  module: `
(function (root, factory) {
  if (typeof define === 'function' && define.amd) {
      define([], factory);
  } else if (typeof module === 'object' && module.exports) {
      module.exports = factory();
  } else {
      root.returnExports = factory();
}
}(typeof self !== 'undefined' ? self : this, function () {
  return require('atomic-promise');
}));
`,
};

function compile({ src, dest }, opts = {}) {
  let done = true;
  const force = !!opts.plugin && opts.plugin.includes(watchify);
  const b = browserify(Object.values(src).map(p => glob.sync(p)), {
    cache: {},
    packageCache: {},
    ...opts,
  })
    .require(`./index.ts`, { expose: pkg.name })
    .plugin(tsify, { global: true, ...require('./tsconfig.json').compilerOptions })
    .on('update', () => void bundle());
  return bundle();

  function bundle() {
    console.time('bundle');
    return b
      .bundle()
      .on("error", err => done = console.log(err + ''))
      .pipe(source(`${pkg.name}.js`))
      .pipe(buffer())
      .once('finish', () => console.timeEnd('bundle'))
      .once("finish", () => done || force || process.exit(1))
      .pipe(gulp.dest(dest));
  }
}

gulp.task('ts:watch', function () {
  return compile(config.ts.test, {
    plugin: [watchify],
  });
});

gulp.task('ts:test', function () {
  return compile(config.ts.test);
});

gulp.task('ts:dist', function () {
  return compile(config.ts.dist)
    .pipe($.unassert())
    .pipe($.header(config.banner))
    .pipe($.footer(config.module))
    .pipe(gulp.dest(config.ts.dist.dest))
    .pipe($.rename({ extname: '.min.js' }))
    .pipe(minify({ output: { comments: /^!/ } }))
    .pipe(gulp.dest(config.ts.dist.dest));
});

gulp.task('karma:watch', function (done) {
  new Server({
    configFile: __dirname + '/karma.conf.js',
    browsers: config.browsers,
    preprocessors: {
      'dist/*.js': ['espower']
    },
  }, done).start();
});

gulp.task('karma:test', function (done) {
  new Server({
    configFile: __dirname + '/karma.conf.js',
    browsers: config.browsers,
    preprocessors: {
      'dist/*.js': ['coverage', 'espower']
    },
    reporters: ['dots', 'coverage'],
    singleRun: true
  }, done).start();
});

gulp.task('karma:ci', function (done) {
  new Server({
    configFile: __dirname + '/karma.conf.js',
    browsers: config.browsers,
    preprocessors: {
      'dist/*.js': ['coverage', 'espower']
    },
    reporters: ['dots', 'coverage', 'coveralls'],
    singleRun: true
  }, done).start();
});

gulp.task('clean', function () {
  return del([config.ts.dist.dest, './gh-pages/assets/**/lib']);
});

gulp.task('install', function () {
  shell('npm i --no-shrinkwrap');
});

gulp.task('update', function () {
  shell('bundle update');
  shell('ncu -ua');
  shell('npm i -DE typescript@next --no-shrinkwrap');
  shell('npm i --no-shrinkwrap');
});

gulp.task('watch', ['clean'], function (done) {
  seq(
    'ts:test',
    [
      'ts:watch',
      'karma:watch'
    ],
    done
  );
});

gulp.task('test', ['clean'], function (done) {
  seq(
    'ts:test',
    'karma:test',
    'ts:dist',
    done
  );
});

gulp.task('site', ['dist'], function () {
  return gulp.src([
    `dist/${pkg.name}.js`,
  ])
    .pipe(gulp.dest('./gh-pages/assets/js/lib'));
});

gulp.task('view', ['site'], function () {
  shell('bundle exec jekyll serve -s ./gh-pages -d ./gh-pages/_site --incremental');
});

gulp.task('dist', ['clean'], function (done) {
  seq(
    'ts:dist',
    done
  );
});

gulp.task('ci', ['clean'], function (done) {
  seq(
    'ts:test',
    'karma:ci',
    'karma:ci',
    'karma:ci',
    'dist',
    'site',
    done
  );
});
<commit_msg>chore: update build scripts<commit_after>const gulp = require('gulp');
const glob = require('glob');
const shell = cmd => require('child_process').execSync(cmd, { stdio: [0, 1, 2] });
const del = require('del');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const $ = require('gulp-load-plugins')();
const seq = require('run-sequence');
const browserify = require('browserify');
const watchify = require('watchify');
const tsify = require('tsify');
const minify = require('gulp-uglify/composer')(require('uglify-es'), console);
const Server = require('karma').Server;

const pkg = require('./package.json');
const config = {
  browsers: ['Chrome', 'Firefox'].concat((os => {
    switch (os) {
      case 'Windows_NT':
        return ['Edge'];
      case 'Darwin':
        return [];
     default:
        return [];
    }
  })(require('os').type())),
  ts: {
    dist: {
      src: [
        '*.ts'
      ],
      dest: 'dist'
    },
    test: {
      src: [
        '*.ts',
        'src/**/*.ts',
        'test/**/*.ts'
      ],
      dest: 'dist'
    }
  },
  banner: [
    `/*! ${pkg.name} v${pkg.version} ${pkg.repository.url} | (c) 2012, ${pkg.author} | ${pkg.license} License */`,
    ''
  ].join('\n'),
  module: `
(function (root, factory) {
  if (typeof define === 'function' && define.amd) {
      define([], factory);
  } else if (typeof module === 'object' && module.exports) {
      module.exports = factory();
  } else {
      root.returnExports = factory();
}
}(typeof self !== 'undefined' ? self : this, function () {
  return require('atomic-promise');
}));
`,
};

function compile({ src, dest }, opts = {}) {
  let done = true;
  const force = !!opts.plugin && opts.plugin.includes(watchify);
  const b = browserify(Object.values(src).map(p => glob.sync(p)), {
    cache: {},
    packageCache: {},
    ...opts,
  })
    .require(`./index.ts`, { expose: pkg.name })
    .plugin(tsify, { global: true, ...require('./tsconfig.json').compilerOptions })
    .on('update', () => void bundle());
  return bundle();

  function bundle() {
    console.time('bundle');
    return b
      .bundle()
      .on("error", err => done = console.log(err + ''))
      .pipe(source(`${pkg.name}.js`))
      .pipe(buffer())
      .once('finish', () => console.timeEnd('bundle'))
      .once("finish", () => done || force || process.exit(1))
      .pipe(gulp.dest(dest));
  }
}

gulp.task('ts:watch', function () {
  return compile(config.ts.test, {
    plugin: [watchify],
  });
});

gulp.task('ts:test', function () {
  return compile(config.ts.test);
});

gulp.task('ts:dist', function () {
  return compile(config.ts.dist)
    .pipe($.unassert())
    .pipe($.header(config.banner))
    .pipe($.footer(config.module))
    .pipe(gulp.dest(config.ts.dist.dest))
    .pipe($.rename({ extname: '.min.js' }))
    .pipe(minify({ output: { comments: /^!/ } }))
    .pipe(gulp.dest(config.ts.dist.dest));
});

gulp.task('karma:watch', function (done) {
  new Server({
    configFile: __dirname + '/karma.conf.js',
    browsers: config.browsers,
    preprocessors: {
      'dist/*.js': ['espower']
    },
  }, done).start();
});

gulp.task('karma:test', function (done) {
  new Server({
    configFile: __dirname + '/karma.conf.js',
    browsers: config.browsers,
    preprocessors: {
      'dist/*.js': ['coverage', 'espower']
    },
    reporters: ['dots', 'coverage'],
    concurrency: 1,
    singleRun: true
  }, done).start();
});

gulp.task('karma:ci', function (done) {
  new Server({
    configFile: __dirname + '/karma.conf.js',
    browsers: config.browsers,
    preprocessors: {
      'dist/*.js': ['coverage', 'espower']
    },
    reporters: ['dots', 'coverage', 'coveralls'],
    concurrency: 1,
    singleRun: true
  }, done).start();
});

gulp.task('clean', function () {
  return del([config.ts.dist.dest, './gh-pages/assets/**/lib']);
});

gulp.task('install', function () {
  shell('npm i --no-shrinkwrap');
});

gulp.task('update', function () {
  shell('bundle update');
  shell('ncu -ua');
  shell('npm i -DE typescript@next --no-shrinkwrap');
  shell('npm i --no-shrinkwrap');
});

gulp.task('watch', ['clean'], function (done) {
  seq(
    'ts:test',
    [
      'ts:watch',
      'karma:watch'
    ],
    done
  );
});

gulp.task('test', ['clean'], function (done) {
  seq(
    'ts:test',
    'karma:test',
    'ts:dist',
    done
  );
});

gulp.task('site', ['dist'], function () {
  return gulp.src([
    `dist/${pkg.name}.js`,
  ])
    .pipe(gulp.dest('./gh-pages/assets/js/lib'));
});

gulp.task('view', ['site'], function () {
  shell('bundle exec jekyll serve -s ./gh-pages -d ./gh-pages/_site --incremental');
});

gulp.task('dist', ['clean'], function (done) {
  seq(
    'ts:dist',
    done
  );
});

gulp.task('ci', ['clean'], function (done) {
  seq(
    'ts:test',
    'karma:ci',
    'karma:ci',
    'karma:ci',
    'dist',
    'site',
    done
  );
});
<|endoftext|>


<commit_before>'use strict';

var gulp	= require('gulp');
var newer	= require('gulp-newer');
var concat	= require('gulp-concat');
var notify	= require('gulp-notify');

require('es6-promise').polyfill();

// Ignore any file prefixed with an underscore //
var less_files = ['src/**/*.less','!src/**/_*.less'];

// Ignore any min files, and the output file //
var css_output = 'all.css';
var css_min_output = 'all.min.css';
var css_files = ['output/**/*.css','output/**/*.min.css','!output/'+css_output];

var js_output = 'all.js';
var js_min_output = 'all.min.js';
var js_files = ['src/**/*.js','output/**/*.min.js','!output/'+js_output];

/* Process the individual LESS files */
gulp.task('less', function() {
	var postcss = require('gulp-postcss');
	var less	= require('gulp-less-sourcemap');

	return gulp.src( less_files )
		.pipe( newer({dest:'output',ext:".css"}) )
		.pipe( postcss([
			require('autoprefixer')
		]) )
		.pipe( less(/*{compress: true}*/) )
		.pipe( gulp.dest('output/') );
});

/* Next, combine the output CSS files */
gulp.task('css', ['less'], function() {
	return gulp.src( css_files )
		.pipe( newer( 'output/'+css_output) )
		.pipe( concat( css_output ) )
		.pipe( gulp.dest( 'output/' ) );
});

/* Finally, minifiy the CSS files */
gulp.task('css-min', ['css'], function() {
	var cssnano	= require('gulp-cssnano');

	return gulp.src( "output/"+css_output )
		.pipe( newer( 'output/'+css_min_output ) )
		.pipe( cssnano() )
		.pipe( concat( css_min_output ) )
		.pipe( gulp.dest('output/') );
});

/* Merge all JS files */
gulp.task('js', function() {
	return gulp.src( js_files )
		.pipe( newer( 'output/'+js_output ) )
		.pipe( concat( js_output ) )
		.pipe( gulp.dest('output/') );
});

/* Minifiy merged file */
gulp.task('js-min', ['js'], function() {
	var uglify = require('gulp-uglify');

	return gulp.src( 'output/'+js_output )
		.pipe( newer( 'output/'+js_min_output ) )
		.pipe( uglify() )
		.pipe( concat( js_min_output ) )
		.pipe( gulp.dest('output/') );
});

/* Nuke the output folder */
gulp.task('clean', function() {
	var del = require('del');

	return del( 'output/**/*' );
});

// TODO: Popup notifications when a watch catches an error/linting error
//		.pipe( notify("hello") )

// NOTE: Use gulp-watch instead: https://www.npmjs.com/package/gulp-watch
//gulp.task('less-watch', ['css','js'] function () {
//	gulp.watch(less_files, ['css'])
//	gulp.watch(js_files, ['js'])
//});

gulp.task('default', ['css-min','js-min'], function() {
});
<commit_msg>rearranged gulpfile to work around postcss sourcemaps bug<commit_after>'use strict';

var gulp	= require('gulp');
var newer	= require('gulp-newer');
var concat	= require('gulp-concat');
var notify	= require('gulp-notify');

require('es6-promise').polyfill();

// Ignore any file prefixed with an underscore //
var less_files = ['src/**/*.less','!src/**/_*.less'];

// Ignore any min files, and the output file //
var css_output = 'all.css';
var css_min_output = 'all.min.css';
var css_files = ['output/**/*.css','output/**/*.min.css','!output/'+css_output];

var js_output = 'all.js';
var js_min_output = 'all.min.js';
var js_files = ['src/**/*.js','!src/**/_*.js','output/**/*.min.js','!output/'+js_output];

/* Process the individual LESS files */
gulp.task('less', function() {
	var sourcemaps	= require('gulp-sourcemaps');
	var less		= require('gulp-less-sourcemap');
	var autoprefix	= require('less-plugin-autoprefix');
	// NOTE: We're running autoprefixer as a less plugin, due to a bug in postcss sourcemaps

	return gulp.src( less_files )
		.pipe( newer({dest:'output',ext:".css"}) )
		.pipe( sourcemaps.init() )
			.pipe( less({
				plugins:[
					new autoprefix(/*{
						browsers: ["last 2 versions"]
					}*/)
				]
			}) )
		.pipe( sourcemaps.write() )
		.pipe( gulp.dest('output/') );
});

/* Next, combine the output CSS files */
gulp.task('css', ['less'], function() {
	// NOTE: PostCSS needs to be run here, due to a bug with sourcemaps
	var postcss = require('gulp-postcss');

	return gulp.src( css_files )
		.pipe( newer( 'output/'+css_output) )
		.pipe( postcss([
//			require('autoprefixer')
		]) )
		.pipe( concat( css_output ) )
		.pipe( gulp.dest( 'output/' ) );
});

/* Finally, minifiy the CSS files */
gulp.task('css-min', ['css'], function() {
	var cssnano	= require('gulp-cssnano');

	return gulp.src( "output/"+css_output )
		.pipe( newer( 'output/'+css_min_output ) )
		.pipe( cssnano() )
		.pipe( concat( css_min_output ) )
		.pipe( gulp.dest('output/') );
});

/* Merge all JS files */
gulp.task('js', function() {
	return gulp.src( js_files )
		.pipe( newer( 'output/'+js_output ) )
		.pipe( concat( js_output ) )
		.pipe( gulp.dest('output/') );
});

/* Minifiy merged file */
gulp.task('js-min', ['js'], function() {
	var uglify = require('gulp-uglify');

	return gulp.src( 'output/'+js_output )
		.pipe( newer( 'output/'+js_min_output ) )
		.pipe( uglify() )
		.pipe( concat( js_min_output ) )
		.pipe( gulp.dest('output/') );
});

/* Nuke the output folder */
gulp.task('clean', function() {
	var del = require('del');

	return del( 'output/**/*' );
});

// TODO: Popup notifications when a watch catches an error/linting error
//		.pipe( notify("hello") )

// NOTE: Use gulp-watch instead: https://www.npmjs.com/package/gulp-watch
//gulp.task('less-watch', ['css','js'] function () {
//	gulp.watch(less_files, ['css'])
//	gulp.watch(js_files, ['js'])
//});

gulp.task('default', ['css-min','js-min'], function() {
});
<|endoftext|>


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

gulp.task('deploy', function() {
  return gulp.src(['{themes,extensions,core}/**/*.{js,css}', 'index.html'])
             .pipe(rsync({
               root: '.',
               hostname: 'people.mozilla.org',
               username: 'mconley2',
               destination: '~/public_html/talks/js-and-dom-for-gecko-hackers-talk'
             }));
});
<commit_msg>Need to send examples to server too<commit_after>var gulp = require('gulp');
var rsync = require('gulp-rsync');

gulp.task('deploy', function() {
  return gulp.src(['{themes,extensions,core,examples}/**/*.{js,css}', 'index.html'])
             .pipe(rsync({
               root: '.',
               hostname: 'people.mozilla.org',
               username: 'mconley2',
               destination: '~/public_html/talks/js-and-dom-for-gecko-hackers-talk'
             }));
});
<|endoftext|>


<commit_before>/**
 * @license
 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
 * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
 * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
 * Code distributed by Google as part of the polymer project is also
 * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
 */

'use strict';

/* eslint-env node */
/* eslint-disable no-console */

let gulp = require('gulp');
let compilerPackage = require('google-closure-compiler');
let sourcemaps = require('gulp-sourcemaps');
let rename = require('gulp-rename');
let closureCompiler = compilerPackage.gulp();
let rollup = require('gulp-rollup');
const size = require('gulp-size');

gulp.task('default', () => {
  return gulp.src('./src/*.js')
    .pipe(sourcemaps.init())
    .pipe(closureCompiler({
      new_type_inf: true,
      compilation_level: 'ADVANCED',
      language_in: 'ES6_STRICT',
      language_out: 'ES5_STRICT',
      isolation_mode: 'IIFE',
      assume_function_wrapper: true,
      js_output_file: 'shadydom.min.js',
      warning_level: 'VERBOSE',
      rewrite_polyfills: false,
      externs: 'externs/shadydom.js'
    }))
    .pipe(size({showFiles: true, showTotal: false, gzip: true}))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./'))
});

gulp.task('debug', () => {
  return gulp.src('src/*.js')
  .pipe(rollup({
    entry: 'src/shadydom.js',
    format: 'iife',
    moduleName: 'shadydom'
  }))
  .pipe(rename('shadydom.min.js'))
  .pipe(size({showFiles: true, showTotal: false, gzip: true}))
  .pipe(gulp.dest('./'))
})
<commit_msg>add the missing original source files content into shadydom.min.js.map<commit_after>/**
 * @license
 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
 * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
 * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
 * Code distributed by Google as part of the polymer project is also
 * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
 */

'use strict';

/* eslint-env node */
/* eslint-disable no-console */

let gulp = require('gulp');
let compilerPackage = require('google-closure-compiler');
let sourcemaps = require('gulp-sourcemaps');
let rename = require('gulp-rename');
let closureCompiler = compilerPackage.gulp();
let rollup = require('gulp-rollup');
const size = require('gulp-size');

gulp.task('default', () => {
  return gulp.src('./src/*.js', {base: '.'})
    .pipe(sourcemaps.init())
    .pipe(closureCompiler({
      new_type_inf: true,
      compilation_level: 'ADVANCED',
      language_in: 'ES6_STRICT',
      language_out: 'ES5_STRICT',
      isolation_mode: 'IIFE',
      assume_function_wrapper: true,
      js_output_file: 'shadydom.min.js',
      warning_level: 'VERBOSE',
      rewrite_polyfills: false,
      externs: 'externs/shadydom.js'
    }))
    .pipe(size({showFiles: true, showTotal: false, gzip: true}))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./'))
});

gulp.task('debug', () => {
  return gulp.src('src/*.js')
  .pipe(rollup({
    entry: 'src/shadydom.js',
    format: 'iife',
    moduleName: 'shadydom'
  }))
  .pipe(rename('shadydom.min.js'))
  .pipe(size({showFiles: true, showTotal: false, gzip: true}))
  .pipe(gulp.dest('./'))
})
<|endoftext|>


<commit_before>var browserify = require('browserify');
var fs = require('fs');
var gulp = require('gulp');
var buffer = require('gulp-buffer');
var header = require('gulp-header');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
var strftime = require('strftime');
var jscs = require('gulp-jscs');

var version = require('./package.json').version;
var date = strftime('%F');

/* Main gulp task to minify and concat assets */
gulp.task('dist', function () {
  var bundleStream = browserify('./index.js').bundle({
    standalone: 'Isomer'
  });

  var banner = fs.readFileSync('./js/banner/copyright.js');
  var bannerMin = fs.readFileSync('./js/banner/copyright.min.js');
  var opts = {
    date: date,
    version: version
  };

  bundleStream
    /* isomer.js */
    .pipe(source('isomer.js'))
    .pipe(buffer())
    .pipe(header(banner, opts))
    .pipe(gulp.dest('./dist'))

    /* isomer.min.js */
    .pipe(uglify())
    .pipe(header(bannerMin, opts))
    .pipe(rename('isomer.min.js'))
    .pipe(gulp.dest('./dist'));

});

gulp.task('lint', function () {
  return gulp
    .src('./js/**/color.js')
    .pipe(jscs());
});

gulp.task('default', ['lint', 'dist']);
<commit_msg>fixed hardcoded linting path in gulpfile<commit_after>var browserify = require('browserify');
var fs = require('fs');
var gulp = require('gulp');
var buffer = require('gulp-buffer');
var header = require('gulp-header');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
var strftime = require('strftime');
var jscs = require('gulp-jscs');

var version = require('./package.json').version;
var date = strftime('%F');

/* Main gulp task to minify and concat assets */
gulp.task('dist', function () {
  var bundleStream = browserify('./index.js').bundle({
    standalone: 'Isomer'
  });

  var banner = fs.readFileSync('./js/banner/copyright.js');
  var bannerMin = fs.readFileSync('./js/banner/copyright.min.js');
  var opts = {
    date: date,
    version: version
  };

  bundleStream
    /* isomer.js */
    .pipe(source('isomer.js'))
    .pipe(buffer())
    .pipe(header(banner, opts))
    .pipe(gulp.dest('./dist'))

    /* isomer.min.js */
    .pipe(uglify())
    .pipe(header(bannerMin, opts))
    .pipe(rename('isomer.min.js'))
    .pipe(gulp.dest('./dist'));

});

gulp.task('lint', function () {
  return gulp
    .src('./js/**/*.js')
    .pipe(jscs());
});

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


<commit_before>// jchck_'s gulpfile

//
// site's dev URL (used in the watch task below)
//

var devUrl			=		'http://vagrant.local/jchck/';

//
// gulp plugin registry
//

var gulp 			=		require('gulp');
var postcss 		=		require('gulp-postcss');
var cssnext 		= 		require('postcss-cssnext');
var atImport		=		require('postcss-import');
var mqpacker		=		require('css-mqpacker');
var cssnano			=		require('cssnano');
var size			=		require('gulp-size');
var	cssvariables	=		require('postcss-css-variables');
var browserSync		=		require('browser-sync').create();

//
// css processing task
//
// $ gulp css
//

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

	// postcss plugin registry
	var postcssPlugins = [
		atImport,
		cssvariables,
		cssnano,
		cssnext({
			'browsers': ['last 2 versions']
		}),
		mqpacker,
	];

	// processing plumbing
	return gulp.src('./src/css/jchck_.css')

		// postcss it
		.pipe(postcss(postcssPlugins))

		// what's the size?
		.pipe(size({gzip: false, showFiles: true, title: 'Processed!'}))
		.pipe(size({gzip: true, showFiles: true, title: 'Processed & gZipped!'}))

		// spit it out
		.pipe(gulp.dest('./dest'))

		// add to the browser sync stream
		.pipe(browserSync.stream());
});

//
// watch task
//
// $ gulp watch
//

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

	browserSync.init({

		// the php files to watch
		files: [
			'{lib,templates}/**/*.php',
			'*.php'
		],

		// the url getting proxied, defined above
		proxy: devUrl,

		// @see https://www.browsersync.io/docs/options/#option-snippetOptions
		snippetOptions: {
			whitelist: ['/wp-admin/admin-ajax.php'],
			blacklist: ['/wp-admin/**']
		}
	});

	// the css files to watch on change runs the css processing task
	gulp.watch(['./src/css/*'], ['css']);
});

//
// default task
//
// $ gulp
//

gulp.task('default', ['css', 'watch']);
<commit_msg>watch /logic directory<commit_after>// jchck_'s gulpfile

//
// site's dev URL (used in the watch task below)
//

var devUrl			=		'http://vagrant.local/jchck/';

//
// gulp plugin registry
//

var gulp 			=		require('gulp');
var postcss 		=		require('gulp-postcss');
var cssnext 		= 		require('postcss-cssnext');
var atImport		=		require('postcss-import');
var mqpacker		=		require('css-mqpacker');
var cssnano			=		require('cssnano');
var size			=		require('gulp-size');
var	cssvariables	=		require('postcss-css-variables');
var browserSync		=		require('browser-sync').create();

//
// css processing task
//
// $ gulp css
//

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

	// postcss plugin registry
	var postcssPlugins = [
		atImport,
		cssvariables,
		cssnano,
		cssnext({
			'browsers': ['last 2 versions']
		}),
		mqpacker,
	];

	// processing plumbing
	return gulp.src('./src/css/jchck_.css')

		// postcss it
		.pipe(postcss(postcssPlugins))

		// what's the size?
		.pipe(size({gzip: false, showFiles: true, title: 'Processed!'}))
		.pipe(size({gzip: true, showFiles: true, title: 'Processed & gZipped!'}))

		// spit it out
		.pipe(gulp.dest('./dest'))

		// add to the browser sync stream
		.pipe(browserSync.stream());
});

//
// watch task
//
// $ gulp watch
//

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

	browserSync.init({

		// the php files to watch
		files: [
			'{logic,templates}/**/*.php',
			'*.php'
		],

		// the url getting proxied, defined above
		proxy: devUrl,

		// @see https://www.browsersync.io/docs/options/#option-snippetOptions
		snippetOptions: {
			whitelist: ['/wp-admin/admin-ajax.php'],
			blacklist: ['/wp-admin/**']
		}
	});

	// the css files to watch on change runs the css processing task
	gulp.watch(['./src/css/*'], ['css']);
});

//
// default task
//
// $ gulp
//

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