<commit_before>'use strict';

//////////////////////////////
// Requires
//////////////////////////////

const path = require('path');
const autoprefixer = require('gulp-autoprefixer');
const browserSync = require('browser-sync').create();
const del = require('del');
const gulp = require('gulp');
const rename = require('gulp-rename');
const sass = require('gulp-sass');
const sassLint = require('gulp-sass-lint');
const sourcemaps = require('gulp-sourcemaps');
const webpack = require('webpack');
const gutil = require('gulp-util');
const Server = require('karma').Server;
const cloptions = require('minimist')(process.argv.slice(2), {
  alias: {
    k: 'keepalive',
  },
  boolean: ['keepalive'],
});

//////////////////////////////
// BrowserSync
//////////////////////////////

gulp.task('browser-sync', () => {
  browserSync.init({
    logPrefix: "Bluemix Components",
    open: false,
    proxy: 'localhost:8080',
    reloadDelay: 500
  });
});

//////////////////////////////
// Clean
//////////////////////////////

// Use: npm run prebuild
gulp.task('clean', () => {
  return del([
    'consumables/css/*.css',
    'consumables/es5/*.{js,map}',
    'demo/*.{js,map}'
  ]);
});

//////////////////////////////
// JavaScript Tasks
//////////////////////////////
gulp.task('scripts:consumables', () => {
  function buildScripts(prod) {
    return new Promise((resolve, reject) => {
      webpack({
        devtool: 'source-maps',
        entry: './consumables/js/es2015/index.js',
        output: {
          path: './consumables/js/es5',
          filename: 'bluemix-components' + (prod ? '.min' : '') + '.js',
          libraryTarget: 'var',
          library: 'BluemixComponents',
        },
        module: {
          loaders: [
            {
              test: /\.js?$/,
              exclude: /node_modules/,
              loaders: ['babel'],
            },
          ],
        },
        plugins: prod ? [new webpack.optimize.UglifyJsPlugin()] : [],
      }, (err, stats) => {
        if (err) {
          reject(new gutil.PluginError('webpack', err));
        } else {
          gutil.log('[webpack]', stats.toString({
            progress: true,
            colors: true,
          }));
          resolve();
        }
      });
    });
  }

  buildScripts() // Expanded ES5
  buildScripts(true); // Minified ES5
});

gulp.task('scripts:demo', (cb) => {
  return gulp.src('consumables/js/es5/*.{js,map}')
    .pipe(gulp.dest('demo'));
  // webpack({
  //   devtool: 'source-maps',
  //   entry: './demo/demo-es2015.js',
  //   output: {
  //     path: './demo',
  //     filename: 'demo.js'
  //   },
  //   module: {
  //     loaders: [
  //       {
  //         test: /\.js?$/,
  //         exclude: /node_modules/,
  //         loaders: ['babel'],
  //       },
  //     ],
  //   },
  // }, (err, stats) => {
  //   if (err) throw new gutil.PluginError('webpack', err);
  //   gutil.log('[webpack]', stats.toString({
  //     progress: true,
  //     colors: true
  //   }));
  //   browserSync.reload();
  //   cb();
  // });
});

gulp.task('scripts', ['scripts:consumables', 'scripts:demo']);

//////////////////////////////
// Sass Tasks
//////////////////////////////

gulp.task('sass:consumables', () => {
  function buildStyles(prod) {
    return gulp.src('consumables/scss/styles.scss')
      .pipe(sourcemaps.init())
      .pipe(sass({
        outputStyle: prod ? 'compressed' : 'expanded'
      }).on('error', sass.logError))
      .pipe(autoprefixer({
        browsers: ['> 1%', 'last 2 versions']
      }))
      .pipe(rename(function (path) {
        if (path.basename === 'styles') {
          path.basename = 'bluemix-components';
        }
        if (prod) {
          path.extname = '.min' + path.extname;
        }
      }))
      .pipe(sourcemaps.write())
      .pipe(gulp.dest('consumables/css'))
      .pipe(browserSync.stream());
  }

  buildStyles(); // Expanded CSS
  buildStyles(true); // Minified CSS
});

gulp.task('sass:demo', () => {
  return gulp.src('demo/**/demo.scss')
    .pipe(sourcemaps.init())
    .pipe(sass({
      outputStyle: 'expanded'
    }).on('error', sass.logError))
    .pipe(autoprefixer({
      browsers: ['> 1%', 'last 2 versions']
    }))
    .pipe(rename({ dirname: '' }))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('demo'))
    .pipe(browserSync.stream());
});

// Temporary: gulp-sass-lint does not seem to be using our .sass-lint.yml
// gulp.task('sass:lint', () => {
//   return gulp.src('consumables/**/*.scss')
//     .pipe(sassLint())
//     .pipe(sassLint.format())
//     .pipe(sassLint.failOnError());
// });

gulp.task('sass', ['sass:consumables', 'sass:demo']);

/////////////////////////////
// Test
/////////////////////////////

gulp.task('test', (done) => {
  new Server({
    configFile: path.resolve(__dirname, 'tests/karma.conf.js'),
    singleRun: !cloptions.keepalive,
  }, done).start();
});

//////////////////////////////
// Running Tasks
//////////////////////////////

gulp.task('watch', () => {
  gulp.watch('./**/*.html').on('change', browserSync.reload);
  gulp.watch(['consumables/**/*.js', 'demo/**/*.js'], ['scripts']);
  gulp.watch(['consumables/**/*.scss', 'demo/**/*.scss'], ['sass']);
});

gulp.task('serve', ['browser-sync', 'watch']);

// Use: npm run build
gulp.task('build', ['sass', 'scripts']);

gulp.task('default', () => {
  console.log('\n\n Please use `$ npm run dev` and navigate to \n http://localhost:3000 to view project locally \n\n');
});
<commit_msg>Fix infinite loop watching files, fixes #957.<commit_after>'use strict';

//////////////////////////////
// Requires
//////////////////////////////

const path = require('path');
const autoprefixer = require('gulp-autoprefixer');
const browserSync = require('browser-sync').create();
const del = require('del');
const gulp = require('gulp');
const rename = require('gulp-rename');
const sass = require('gulp-sass');
const sassLint = require('gulp-sass-lint');
const sourcemaps = require('gulp-sourcemaps');
const webpack = require('webpack');
const gutil = require('gulp-util');
const Server = require('karma').Server;
const cloptions = require('minimist')(process.argv.slice(2), {
  alias: {
    k: 'keepalive',
  },
  boolean: ['keepalive'],
});

//////////////////////////////
// BrowserSync
//////////////////////////////

gulp.task('browser-sync', () => {
  browserSync.init({
    logPrefix: "Bluemix Components",
    open: false,
    proxy: 'localhost:8080',
    reloadDelay: 500
  });
});

//////////////////////////////
// Clean
//////////////////////////////

// Use: npm run prebuild
gulp.task('clean', () => {
  return del([
    'consumables/css/*.css',
    'consumables/es5/*.{js,map}',
    'demo/*.{js,map}'
  ]);
});

//////////////////////////////
// JavaScript Tasks
//////////////////////////////
gulp.task('scripts:consumables', () => {
  function buildScripts(prod) {
    return new Promise((resolve, reject) => {
      webpack({
        devtool: 'source-maps',
        entry: './consumables/js/es2015/index.js',
        output: {
          path: './consumables/js/es5',
          filename: 'bluemix-components' + (prod ? '.min' : '') + '.js',
          libraryTarget: 'var',
          library: 'BluemixComponents',
        },
        module: {
          loaders: [
            {
              test: /\.js?$/,
              exclude: /node_modules/,
              loaders: ['babel'],
            },
          ],
        },
        plugins: prod ? [new webpack.optimize.UglifyJsPlugin()] : [],
      }, (err, stats) => {
        if (err) {
          reject(new gutil.PluginError('webpack', err));
        } else {
          gutil.log('[webpack]', stats.toString({
            progress: true,
            colors: true,
          }));
          resolve();
        }
      });
    });
  }

  buildScripts() // Expanded ES5
  buildScripts(true); // Minified ES5
});

gulp.task('scripts:demo', (cb) => {
  return gulp.src('consumables/js/es5/*.{js,map}')
    .pipe(gulp.dest('demo'));
  // webpack({
  //   devtool: 'source-maps',
  //   entry: './demo/demo-es2015.js',
  //   output: {
  //     path: './demo',
  //     filename: 'demo.js'
  //   },
  //   module: {
  //     loaders: [
  //       {
  //         test: /\.js?$/,
  //         exclude: /node_modules/,
  //         loaders: ['babel'],
  //       },
  //     ],
  //   },
  // }, (err, stats) => {
  //   if (err) throw new gutil.PluginError('webpack', err);
  //   gutil.log('[webpack]', stats.toString({
  //     progress: true,
  //     colors: true
  //   }));
  //   browserSync.reload();
  //   cb();
  // });
});

gulp.task('scripts', ['scripts:consumables', 'scripts:demo']);

//////////////////////////////
// Sass Tasks
//////////////////////////////

gulp.task('sass:consumables', () => {
  function buildStyles(prod) {
    return gulp.src('consumables/scss/styles.scss')
      .pipe(sourcemaps.init())
      .pipe(sass({
        outputStyle: prod ? 'compressed' : 'expanded'
      }).on('error', sass.logError))
      .pipe(autoprefixer({
        browsers: ['> 1%', 'last 2 versions']
      }))
      .pipe(rename(function (path) {
        if (path.basename === 'styles') {
          path.basename = 'bluemix-components';
        }
        if (prod) {
          path.extname = '.min' + path.extname;
        }
      }))
      .pipe(sourcemaps.write())
      .pipe(gulp.dest('consumables/css'))
      .pipe(browserSync.stream());
  }

  buildStyles(); // Expanded CSS
  buildStyles(true); // Minified CSS
});

gulp.task('sass:demo', () => {
  return gulp.src('demo/**/demo.scss')
    .pipe(sourcemaps.init())
    .pipe(sass({
      outputStyle: 'expanded'
    }).on('error', sass.logError))
    .pipe(autoprefixer({
      browsers: ['> 1%', 'last 2 versions']
    }))
    .pipe(rename({ dirname: '' }))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('demo'))
    .pipe(browserSync.stream());
});

// Temporary: gulp-sass-lint does not seem to be using our .sass-lint.yml
// gulp.task('sass:lint', () => {
//   return gulp.src('consumables/**/*.scss')
//     .pipe(sassLint())
//     .pipe(sassLint.format())
//     .pipe(sassLint.failOnError());
// });

gulp.task('sass', ['sass:consumables', 'sass:demo']);

/////////////////////////////
// Test
/////////////////////////////

gulp.task('test', (done) => {
  new Server({
    configFile: path.resolve(__dirname, 'tests/karma.conf.js'),
    singleRun: !cloptions.keepalive,
  }, done).start();
});

//////////////////////////////
// Running Tasks
//////////////////////////////

gulp.task('watch', () => {
  gulp.watch('./**/*.html').on('change', browserSync.reload);
  gulp.watch(['consumables/**/*.js', '!**/es5/*.js'], ['scripts']);
  gulp.watch(['consumables/**/*.scss', 'demo/**/*.scss'], ['sass']);
});

gulp.task('serve', ['browser-sync', 'watch']);

// Use: npm run build
gulp.task('build', ['sass', 'scripts']);

gulp.task('default', () => {
  console.log('\n\n Please use `$ npm run dev` and navigate to \n http://localhost:3000 to view project locally \n\n');
});
<|endoftext|>


<commit_before>'use strict';

/*!
 * Escaper
 * https://github.com/kobezzza/Escaper
 *
 * Released under the MIT license
 * https://github.com/kobezzza/Escaper/blob/master/LICENSE
 */

const
	gulp = require('gulp'),
	fs = require('fs'),
	async = require('async'),
	through = require('through2');

const
	babel = require('rollup-plugin-babel'),
	monic = require('gulp-monic'),
	rollup = require('gulp-rollup'),
	bump = require('gulp-bump'),
	gcc = require('gulp-closure-compiler'),
	header = require('gulp-header'),
	wrap = require('gulp-wrap'),
	replace = require('gulp-replace'),
	cached = require('gulp-cached'),
	download = require('gulp-download'),
	istanbul = require('gulp-istanbul'),
	jasmine = require('gulp-jasmine'),
	run = require('gulp-run');

function getVersion() {
	const file = fs.readFileSync('./src/escaper.js');
	return /VERSION\s*(?::|=)\s*\[(\d+,\s*\d+,\s*\d+)]/.exec(file)[1]
		.split(/\s*,\s*/)
		.join('.');
}

function getHead(opt_version) {
	return '' +
		'/*!\n' +
		` * Escaper${opt_version ? ` v${getVersion()}` : ''}\n` +
		' * https://github.com/kobezzza/Escaper\n' +
		' *\n' +
		' * Released under the MIT license\n' +
		' * https://github.com/kobezzza/Escaper/blob/master/LICENSE\n';
}

function error(cb) {
	return (err) => {
		console.error(err.message);
		cb();
	};
}

const
	headRgxp = /(\/\*![\s\S]*?\*\/\n{2})/;

let
	readyToWatcher = null;

gulp.task('copyright', (cb) => {
	gulp.src('./LICENSE')
		.pipe(replace(/(Copyright \(c\) )(\d+)-?(\d*)/, (sstr, intro, from, to) => {
			const year = new Date().getFullYear();
			return intro + from + (to || from != year ? `-${year}` : '');
		}))

		.pipe(gulp.dest('./'))
		.on('end', cb);
});

gulp.task('head', (cb) => {
	readyToWatcher = false;

	const
		fullHead = `${getHead()} */\n\n`;

	gulp.src(['./@(src|spec)/*.js', './@(externs|gulpfile).js', './predefs/src/index.js'], {base: './'})
		.pipe(through.obj(function (file, enc, cb) {
			if (!headRgxp.exec(file.contents.toString()) || RegExp.$1 !== fullHead) {
				this.push(file);
			}

			return cb();
		}))

		.pipe(replace(headRgxp, ''))
		.pipe(header(fullHead))
		.pipe(gulp.dest('./'))
		.on('end', () => {
			readyToWatcher = true;
			cb();
		});
});

gulp.task('build', (cb) => {
	const fullHead =
		getHead(true) +
		' *\n' +
		` * Date: ${new Date().toUTCString()}\n` +
		' */\n\n';

	gulp.src('./src/escaper.js')
		.pipe(cached('build'))
		.pipe(rollup({
			format: 'umd',
			moduleId: 'Escaper',
			moduleName: 'Escaper',
			plugins: [babel()]
		}))

		.on('error', error(cb))
		.pipe(replace(headRgxp, ''))
		.pipe(header(fullHead))
		.pipe(gulp.dest('./dist'))
		.on('end', cb);
});

gulp.task('bump', (cb) => {
	gulp.src('./*.json')
		.pipe(bump({version: getVersion()}))
		.pipe(gulp.dest('./'))
		.on('end', cb);
});

gulp.task('npmignore', (cb) => {
	gulp.src('./.npmignore')
		.pipe(replace(/([\s\S]*?)(?=# NPM ignore list)/, `${fs.readFileSync('./.gitignore')}\n`))
		.pipe(gulp.dest('./'))
		.on('end', cb);
});

gulp.task('predefs', (cb) => {
	async.parallel([
		(cb) => {
			download([
				'https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/jasmine.js'
			])
				.on('error', error(cb))
				.pipe(gulp.dest('./predefs/src/ws'))
				.on('end', function () {
					gulp.src('./predefs/src/index.js')
						.pipe(monic())
						.on('error', error(cb))
						.pipe(gulp.dest('./predefs/build'))
						.on('end', cb);
				});
		},

		(cb) => {
			run('bower install').exec()
				.on('error', error(cb))
				.on('finish', cb);
		}

	], cb);
});

function compile(cb) {
	gulp.src('./dist/escaper.js')
		.pipe(cached('compile'))
		.pipe(gcc({
			fileName: 'escaper.min.js',
			compilerPath: './bower_components/closure-compiler/compiler.jar',
			continueWithWarnings: true,

			compilerFlags: {
				compilation_level: 'ADVANCED',
				use_types_for_optimization: null,

				language_in: 'ES6',
				language_out: 'ES5',

				externs: [
					'./predefs/build/index.js'
				],

				jscomp_off: [
					'nonStandardJsDocs'
				],

				jscomp_warning: [
					'invalidCasts',
					'accessControls',
					'checkDebuggerStatement',
					'checkRegExp',
					'checkTypes',
					'const',
					'constantProperty',
					'deprecated',
					'externsValidation',
					'missingProperties',
					'visibility',
					'missingReturn',
					'duplicate',
					'internetExplorerChecks',
					'suspiciousCode',
					'uselessCode',
					'misplacedTypeAnnotation',
					'typeInvalidation'
				]
			}
		}))

		.on('error', error(cb))

		.pipe(wrap('(function(){\'use strict\';<%= contents %>}).call(this);'))
		.pipe(header(`/*! Escaper v${getVersion()} | https://github.com/kobezzza/Escaper/blob/master/LICENSE */\n`))

		.pipe(gulp.dest('./dist'))
		.on('end', cb);
}

gulp.task('compile', ['predefs', 'build'], compile);
gulp.task('fast-compile', ['build'], compile);
gulp.task('full-build', ['compile'], test);

function test(cb) {
	gulp.src('./dist/escaper.min.js')
		.pipe(istanbul())
		.pipe(istanbul.hookRequire())
		.on('finish', () => {
			gulp.src('./spec/index_spec.js')
				.pipe(jasmine())
				.on('error', error(cb))
				.pipe(istanbul.writeReports())
				.on('end', cb);
		});
}

gulp.task('test-dev', ['fast-compile'], test);
gulp.task('test', test);
gulp.task('yaspeller', (cb) => {
	run('yaspeller ./').exec()
		.on('error', error(cb))
		.on('finish', cb);
});

gulp.task('watch', ['default'], () => {
	function unbind(name) {
		return (e) => {
			if (e.type === 'deleted') {
				delete cached.caches[name][e.path];
			}
		};
	}

	async.whilst(
		() =>
			readyToWatcher === false,

		(cb) =>
			setTimeout(cb, 500),

		() => {
			gulp.watch('./src/escaper.js', ['test-dev', 'bump']).on('change', unbind('build'));
			gulp.watch('./spec/*.js', ['test']);
			gulp.watch('./*.md', ['yaspeller']);
			gulp.watch('./.gitignore', ['npmignore']);
		}

	);
});

gulp.task('default', ['copyright', 'head', 'full-build', 'bump', 'yaspeller', 'npmignore']);
<commit_msg>:wrench:<commit_after>'use strict';

/*!
 * Escaper
 * https://github.com/kobezzza/Escaper
 *
 * Released under the MIT license
 * https://github.com/kobezzza/Escaper/blob/master/LICENSE
 */

const
	gulp = require('gulp'),
	fs = require('fs'),
	async = require('async'),
	through = require('through2');

const
	babel = require('rollup-plugin-babel'),
	monic = require('gulp-monic'),
	rollup = require('gulp-rollup'),
	bump = require('gulp-bump'),
	gcc = require('gulp-closure-compiler'),
	header = require('gulp-header'),
	wrap = require('gulp-wrap'),
	replace = require('gulp-replace'),
	cached = require('gulp-cached'),
	download = require('gulp-download'),
	istanbul = require('gulp-istanbul'),
	jasmine = require('gulp-jasmine'),
	run = require('gulp-run');

function getVersion() {
	const file = fs.readFileSync('./src/escaper.js');
	return /VERSION\s*(?::|=)\s*\[(\d+,\s*\d+,\s*\d+)]/.exec(file)[1]
		.split(/\s*,\s*/)
		.join('.');
}

function getHead(opt_version) {
	return '' +
		'/*!\n' +
		` * Escaper${opt_version ? ` v${getVersion()}` : ''}\n` +
		' * https://github.com/kobezzza/Escaper\n' +
		' *\n' +
		' * Released under the MIT license\n' +
		' * https://github.com/kobezzza/Escaper/blob/master/LICENSE\n';
}

function error(cb) {
	return (err) => {
		console.error(err.message);
		cb();
	};
}

const
	headRgxp = /(\/\*![\s\S]*?\*\/\n{2})/;

let
	readyToWatcher = null;

gulp.task('copyright', (cb) => {
	gulp.src('./LICENSE')
		.pipe(replace(/(Copyright \(c\) )(\d+)-?(\d*)/, (sstr, intro, from, to) => {
			const year = new Date().getFullYear();
			return intro + from + (to || from != year ? `-${year}` : '');
		}))

		.pipe(gulp.dest('./'))
		.on('end', cb);
});

gulp.task('head', (cb) => {
	readyToWatcher = false;

	const
		fullHead = `${getHead()} */\n\n`;

	gulp.src(['./@(src|spec)/*.js', './@(externs|gulpfile).js', './predefs/src/index.js'], {base: './'})
		.pipe(through.obj(function (file, enc, cb) {
			if (!headRgxp.exec(file.contents.toString()) || RegExp.$1 !== fullHead) {
				this.push(file);
			}

			return cb();
		}))

		.pipe(replace(headRgxp, ''))
		.pipe(header(fullHead))
		.pipe(gulp.dest('./'))
		.on('end', () => {
			readyToWatcher = true;
			cb();
		});
});

gulp.task('build', (cb) => {
	const fullHead =
		getHead(true) +
		' *\n' +
		` * Date: ${new Date().toUTCString()}\n` +
		' */\n\n';

	gulp.src('./src/escaper.js')
		.pipe(cached('build'))
		.pipe(rollup({
			format: 'umd',
			moduleId: 'Escaper',
			moduleName: 'Escaper',
			plugins: [babel()]
		}))

		.on('error', error(cb))
		.pipe(replace(headRgxp, ''))
		.pipe(header(fullHead))
		.pipe(wrap('<%= contents %>\n\n'))
		.pipe(gulp.dest('./dist'))
		.on('end', cb);
});

gulp.task('bump', (cb) => {
	gulp.src('./*.json')
		.pipe(bump({version: getVersion()}))
		.pipe(gulp.dest('./'))
		.on('end', cb);
});

gulp.task('npmignore', (cb) => {
	gulp.src('./.npmignore')
		.pipe(replace(/([\s\S]*?)(?=# NPM ignore list)/, `${fs.readFileSync('./.gitignore')}\n`))
		.pipe(gulp.dest('./'))
		.on('end', cb);
});

gulp.task('predefs', (cb) => {
	async.parallel([
		(cb) => {
			download([
				'https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/jasmine.js'
			])
				.on('error', error(cb))
				.pipe(gulp.dest('./predefs/src/ws'))
				.on('end', function () {
					gulp.src('./predefs/src/index.js')
						.pipe(monic())
						.on('error', error(cb))
						.pipe(gulp.dest('./predefs/build'))
						.on('end', cb);
				});
		},

		(cb) => {
			run('bower install').exec()
				.on('error', error(cb))
				.on('finish', cb);
		}

	], cb);
});

function compile(cb) {
	gulp.src('./dist/escaper.js')
		.pipe(cached('compile'))
		.pipe(gcc({
			fileName: 'escaper.min.js',
			compilerPath: './bower_components/closure-compiler/compiler.jar',
			continueWithWarnings: true,
			compilerFlags: {
				compilation_level: 'ADVANCED',
				use_types_for_optimization: null,

				language_in: 'ES6',
				language_out: 'ES5',

				externs: [
					'./predefs/build/index.js'
				],

				jscomp_off: [
					'nonStandardJsDocs'
				],

				jscomp_warning: [
					'invalidCasts',
					'accessControls',
					'checkDebuggerStatement',
					'checkRegExp',
					'checkTypes',
					'const',
					'constantProperty',
					'deprecated',
					'externsValidation',
					'missingProperties',
					'visibility',
					'missingReturn',
					'duplicate',
					'internetExplorerChecks',
					'suspiciousCode',
					'uselessCode',
					'misplacedTypeAnnotation',
					'typeInvalidation'
				]
			}
		}))

		.on('error', error(cb))
		.pipe(wrap('(function(){\'use strict\';<%= contents %>}).call(this);\n\n'))
		.pipe(header(`/*! Escaper v${getVersion()} | https://github.com/kobezzza/Escaper/blob/master/LICENSE */\n`))
		.pipe(gulp.dest('./dist'))
		.on('end', cb);
}

gulp.task('compile', ['predefs', 'build'], compile);
gulp.task('fast-compile', ['build'], compile);
gulp.task('full-build', ['compile'], test);

function test(cb) {
	gulp.src('./dist/escaper.min.js')
		.pipe(istanbul())
		.pipe(istanbul.hookRequire())
		.on('finish', () => {
			gulp.src('./spec/index_spec.js')
				.pipe(jasmine())
				.on('error', error(cb))
				.pipe(istanbul.writeReports())
				.on('end', cb);
		});
}

gulp.task('test-dev', ['fast-compile'], test);
gulp.task('test', test);
gulp.task('yaspeller', (cb) => {
	run('yaspeller ./').exec()
		.on('error', error(cb))
		.on('finish', cb);
});

gulp.task('watch', ['default'], () => {
	function unbind(name) {
		return (e) => {
			if (e.type === 'deleted') {
				delete cached.caches[name][e.path];
			}
		};
	}

	async.whilst(
		() =>
			readyToWatcher === false,

		(cb) =>
			setTimeout(cb, 500),

		() => {
			gulp.watch('./src/escaper.js', ['test-dev', 'bump']).on('change', unbind('build'));
			gulp.watch('./spec/*.js', ['test']);
			gulp.watch('./*.md', ['yaspeller']);
			gulp.watch('./.gitignore', ['npmignore']);
		}

	);
});

gulp.task('default', ['copyright', 'head', 'full-build', 'bump', 'yaspeller', 'npmignore']);
<|endoftext|>


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

// gulp.task('webserver', function() {
//   connect.server({
//     livereload: true
//   });
// });

var webserver = require('gulp-webserver');

gulp.task('webserver', function() {
  gulp.src('app')
    .pipe(webserver({
      livereload: true,
      directoryListing: {
        enable:true,
        path: 'index.html'
      },
      open: true
    }));
});

gulp.task('heroku', function() {
  gulp.src('app')
    .pipe(webserver({
      livereload: false,
      host: '',
      port: process.env.PORT,
      directoryListing: {
        enable:true,
        path: 'index.html'
      },
      open: false
    }));
});

gulp.task('serveprod', function() {
  connect.server({
    root: 'app',
    host: process.env.HOST || '0.0.0.0',
    port: process.env.PORT,
    livereload: false,
    open: false
  });
});

gulp.task('less', function() {
  gulp.src('app/styles/app.less')
    .pipe(less())
    .pipe(gulp.dest('app/styles'))
    .pipe(connect.reload());
});

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

gulp.task('default', ['less', 'webserver', 'watch']);
<commit_msg>trying to add generic host<commit_after>var gulp = require('gulp'),
  connect = require('gulp-connect'),
  less = require('gulp-less');

// gulp.task('webserver', function() {
//   connect.server({
//     livereload: true
//   });
// });

var webserver = require('gulp-webserver');

gulp.task('webserver', function() {
  gulp.src('app')
    .pipe(webserver({
      livereload: true,
      directoryListing: {
        enable:true,
        path: 'index.html'
      },
      open: true
    }));
});

gulp.task('heroku', function() {
  gulp.src('app')
    .pipe(webserver({
      livereload: false,
      host: '',
      port: process.env.PORT,
      directoryListing: {
        enable:true,
        path: 'index.html'
      },
      open: false
    }));
});

gulp.task('serveprod', function() {
  connect.server({
    root: 'app',
    host: process.env.HOST,
    port: process.env.PORT,
    livereload: false,
    open: false
  });
});

gulp.task('less', function() {
  gulp.src('app/styles/app.less')
    .pipe(less())
    .pipe(gulp.dest('app/styles'))
    .pipe(connect.reload());
});

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

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


<commit_before>var gulp       	= require('gulp');
var browserify 	= require('browserify');
var watchify   	= require('watchify');
var to5ify      = require("6to5ify");
var connect    	= require('gulp-connect');
var vinylPaths 	= require('vinyl-paths');
var source     	= require('vinyl-source-stream');
var del        	= require('del');
var gulpif     	= require('gulp-if');
var gutil      	= require('gulp-util');
var sass 			 	= require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps  = require('gulp-sourcemaps');
var runSequence = require('run-sequence');
var deploy = require('gulp-gh-pages');

var conf = {
  src: ['**', '!js{,/**}', '!assets/scss{,/**}'],
  js:     ['./src/js/*.js', './src/js/**/*.js'],
  scss: ['./src/scss/**/*.scss'],
  entry: './src/js/app.js',
  dist:   './target/'
};

var isProd = true;

gulp.task('deploy', function () {
    return gulp.src(conf.dist + '**/*')
        .pipe(deploy());
});

gulp.task('clean', function () {
	return gulp.src(conf.dist)
    .pipe(vinylPaths(del))
    .on('error', gutil.log);
});

gulp.task('copy', function () {
  gulp.src(conf.src, {cwd: './src'})
    .pipe(gulp.dest(conf.dist))
    .pipe(connect.reload())
    .on('error', gutil.log);
});

gulp.task('css', function () {
  var dest = conf.dist + 'css/';

	return gulp.src(conf.scss)
         .pipe(gulpif(!isProd, sourcemaps.init()))
         .pipe(sass({
         	errLogToConsole: !isProd,
         	outputStyle: isProd ? 'compressed' : 'expanded',
         	includePaths: [require('node-bourbon').includePaths]
         }))
         .pipe(autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false
        	}))
         .pipe(gulpif(!isProd, sourcemaps.write()))
         .pipe(gulp.dest(dest))
         .pipe(connect.reload())
         .on('error', gutil.log);
});

gulp.task('scripts', function () {
  var bundler = browserify({
    cache: {}, packageCache: {}, fullPaths: false,
    paths: ['./src/js/libs'],
    entries: [conf.entry],
    debug: !isProd
  })
  .transform(to5ify);

  var bundlee = function() {
    return bundler
      .bundle()
      .pipe(source('bundle.js'))
      //.pipe(jshint('.jshintrc'))
      //.pipe(jshint.reporter('default'))
      //.pipe(gulpif(!watching, streamify(uglify({outSourceMaps: false}))))
      .pipe(gulp.dest(conf.dist + 'js'))
      .pipe(connect.reload())
      .on('error', gutil.log);
  };

  if (!isProd) {
    bundler = watchify(bundler);
    bundler.on('update', function (files) {
    	gutil.log('Watchify Update', gutil.colors.magenta(files.map(function (file) {
    		return file.replace(__dirname, '')
    	}).join(', ')))
    	bundlee(files);

    })
  }

  return bundlee();
});

gulp.task('connect', function () {
  connect.server({
    root: [conf.dist],
    port: 9000,
    livereload: true,
    middleware: function (connect, opt) {
    	var proxy = function (localRequest, localResponse, next) {
    		var t = /(\.js|html|css|ico)|^\/$/gi
    		console.log(localRequest.url)
    		if (!t.test(localRequest.url)) {
    			var parts = require('url').parse('http://' + localRequest.url.slice(1));
    			var options = {
    				host: parts.host,
    				path: parts.path
    			};
    			require('http').request(options, function (remoteRequest) {
    				if (remoteRequest.statusCode === 200) {
    					localResponse.writeHead(200, {
    					    'Content-Type': remoteRequest.headers['content-type']
    					});
    					remoteRequest.pipe(localResponse);
    				} else {
    					localResponse.writeHead(remoteRequest.statusCode);
    					localResponse.end();
    				}
    			}).end();
    		} else {
    			next();
    		}
    	};
    	return [proxy];
    }
  });
});

gulp.task('watch', function () {
	gulp.watch(conf.scss, ['css']);
  gulp.watch('./src/**/*.{html,png,jpeg,jpg,json}', ['copy']);
 // gulp.watch(conf.js, ['scripts']);
});

gulp.task('setdev', function () {
	isProd = false;
});

gulp.task('build', function(callback) {
  runSequence('clean', ['copy', 'css', 'scripts'], callback);
});

gulp.task('dev', ['setdev', 'connect', 'watch', 'build'])
gulp.task('default', ['build']);
<commit_msg>removed url logging from proxy middleware in connect<commit_after>var gulp       	= require('gulp');
var browserify 	= require('browserify');
var watchify   	= require('watchify');
var to5ify      = require("6to5ify");
var connect    	= require('gulp-connect');
var vinylPaths 	= require('vinyl-paths');
var source     	= require('vinyl-source-stream');
var del        	= require('del');
var gulpif     	= require('gulp-if');
var gutil      	= require('gulp-util');
var sass 			 	= require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps  = require('gulp-sourcemaps');
var runSequence = require('run-sequence');
var deploy = require('gulp-gh-pages');

var conf = {
  src: ['**', '!js{,/**}', '!assets/scss{,/**}'],
  js:     ['./src/js/*.js', './src/js/**/*.js'],
  scss: ['./src/scss/**/*.scss'],
  entry: './src/js/app.js',
  dist:   './target/'
};

var isProd = true;

gulp.task('deploy', function () {
    return gulp.src(conf.dist + '**/*')
        .pipe(deploy());
});

gulp.task('clean', function () {
	return gulp.src(conf.dist)
    .pipe(vinylPaths(del))
    .on('error', gutil.log);
});

gulp.task('copy', function () {
  gulp.src(conf.src, {cwd: './src'})
    .pipe(gulp.dest(conf.dist))
    .pipe(connect.reload())
    .on('error', gutil.log);
});

gulp.task('css', function () {
  var dest = conf.dist + 'css/';

	return gulp.src(conf.scss)
         .pipe(gulpif(!isProd, sourcemaps.init()))
         .pipe(sass({
         	errLogToConsole: !isProd,
         	outputStyle: isProd ? 'compressed' : 'expanded',
         	includePaths: [require('node-bourbon').includePaths]
         }))
         .pipe(autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false
        	}))
         .pipe(gulpif(!isProd, sourcemaps.write()))
         .pipe(gulp.dest(dest))
         .pipe(connect.reload())
         .on('error', gutil.log);
});

gulp.task('scripts', function () {
  var bundler = browserify({
    cache: {}, packageCache: {}, fullPaths: false,
    paths: ['./src/js/libs'],
    entries: [conf.entry],
    debug: !isProd
  })
  .transform(to5ify);

  var bundlee = function() {
    return bundler
      .bundle()
      .pipe(source('bundle.js'))
      //.pipe(jshint('.jshintrc'))
      //.pipe(jshint.reporter('default'))
      //.pipe(gulpif(!watching, streamify(uglify({outSourceMaps: false}))))
      .pipe(gulp.dest(conf.dist + 'js'))
      .pipe(connect.reload())
      .on('error', gutil.log);
  };

  if (!isProd) {
    bundler = watchify(bundler);
    bundler.on('update', function (files) {
    	gutil.log('Watchify Update', gutil.colors.magenta(files.map(function (file) {
    		return file.replace(__dirname, '')
    	}).join(', ')))
    	bundlee(files);

    })
  }

  return bundlee();
});

gulp.task('connect', function () {
  connect.server({
    root: [conf.dist],
    port: 9000,
    livereload: true,
    middleware: function (connect, opt) {
    	var proxy = function (localRequest, localResponse, next) {
    		var t = /(\.js|html|css|ico)|^\/$/gi
    		if (!t.test(localRequest.url)) {
    			var parts = require('url').parse('http://' + localRequest.url.slice(1));
    			var options = {
    				host: parts.host,
    				path: parts.path
    			};
    			require('http').request(options, function (remoteRequest) {
    				if (remoteRequest.statusCode === 200) {
    					localResponse.writeHead(200, {
    					    'Content-Type': remoteRequest.headers['content-type']
    					});
    					remoteRequest.pipe(localResponse);
    				} else {
    					localResponse.writeHead(remoteRequest.statusCode);
    					localResponse.end();
    				}
    			}).end();
    		} else {
    			next();
    		}
    	};
    	return [proxy];
    }
  });
});

gulp.task('watch', function () {
	gulp.watch(conf.scss, ['css']);
  gulp.watch('./src/**/*.{html,png,jpeg,jpg,json}', ['copy']);
 // gulp.watch(conf.js, ['scripts']);
});

gulp.task('setdev', function () {
	isProd = false;
});

gulp.task('build', function(callback) {
  runSequence('clean', ['copy', 'css', 'scripts'], callback);
});

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


<commit_before>'use strict';

var gulp = require('gulp');
var sass = require('gulp-sass');

gulp.task('sass', function() {
  gulp.src('./sass/**/*.scss').
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('./dist/css'));
});

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

gulp.task('default', ['sass:watch'])
<commit_msg>Fixing gulp syntax<commit_after>'use strict';

var gulp = require('gulp');
var sass = require('gulp-sass');

gulp.task('sass', function() {
  gulp.src('./sass/**/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('./dist/css'));
});

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

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


<commit_before>//initialize all of our variables
var app, base, concat, directory, gulp, gutil, hostname, path, refresh, sass, uglify, imagemin, cache, minifyCSS, clean, connect;

//load all of our dependencies
//add more here if you want to include more libraries
gulp        = require('gulp');
gutil       = require('gulp-util');
concat      = require('gulp-concat');
uglify      = require('gulp-uglify');
sass        = require('gulp-sass');
imagemin    = require('gulp-imagemin');
cache       = require('gulp-cache');
minifyCSS   = require('gulp-minify-css');
clean       = require('gulp-clean');
connect     = require('gulp-connect');

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

//compressing images & handle SVG files
gulp.task('images', function(tmp) {
    console.log(tmp);
    gulp.src(['app/images/*.jpg', 'app/images/*.png'])
        .pipe(imagemin({ optimizationLevel: 5, progressive: true, interlaced: true }));
});

//compressing images & handle SVG files
gulp.task('images-deploy', function() {
    gulp.src(['app/images/**/*'])
        .pipe(gulp.dest('dist/images'));
});

//compiling our Javascripts
gulp.task('scripts', function() {
    //this is where our dev JS scripts are
    return gulp.src('app/scripts/src/**/*.js')
                //this is the filename of the compressed version of our JS
               .pipe(concat('app.js'))
               //catch errors
               .on('error', gutil.log)
               //compress :D
               .pipe(uglify())
               //where we will store our finalized, compressed script
               .pipe(gulp.dest('app/scripts'))
               //notify LiveReload to refresh
               .pipe(connect.reload());
});

//compiling our Javascripts for deployment
gulp.task('scripts-deploy', function() {
    //this is where our dev JS scripts are
    return gulp.src('app/scripts/src/**/*.js')
                //this is the filename of the compressed version of our JS
               .pipe(concat('app.js'))
               //compress :D
               .pipe(uglify())
               //where we will store our finalized, compressed script
               .pipe(gulp.dest('dist/scripts'));
});

//compiling our SCSS files
gulp.task('styles', function() {
    //the initializer / master SCSS file, which will just be a file that imports everything
    return gulp.src('app/styles/scss/init.scss')
                //include SCSS and list every "include" folder
               .pipe(sass({
                      errLogToConsole: true,
                      includePaths: [
                          'app/styles/scss/'
                      ]
               }))
               //catch errors
               .on('error', gutil.log)
               //the final filename of our combined css file
               .pipe(concat('styles.css'))
               //where to save our final, compressed css file
               .pipe(gulp.dest('app/styles'))
               //notify LiveReload to refresh
               .pipe(connect.reload());
});

//compiling our SCSS files for deployment
gulp.task('styles-deploy', function() {
    //the initializer / master SCSS file, which will just be a file that imports everything
    return gulp.src('app/styles/scss/init.scss')
                //include SCSS includes folder
               .pipe(sass({
                      includePaths: [
                          'app/styles/scss',
                      ]
               }))
               //the final filename of our combined css file
               .pipe(concat('styles.css'))
               .pipe(minifyCSS())
               //where to save our final, compressed css file
               .pipe(gulp.dest('dist/styles'));
});

//basically just keeping an eye on all HTML files
gulp.task('html', function() {
    //watch any and all HTML files and refresh when something changes
    return gulp.src('app/*.html')
        .pipe(connect.reload())
       //catch errors
       .on('error', gutil.log);
});

//migrating over all HTML files for deployment
gulp.task('html-deploy', function() {
    //grab everything, which should include htaccess, robots, etc
    gulp.src('app/*')
        .pipe(gulp.dest('dist'));

    //grab any hidden files too
    gulp.src('app/.*')
        .pipe(gulp.dest('dist'));

    gulp.src('app/fonts/**/*')
        .pipe(gulp.dest('dist/fonts'));

    //grab all of the styles
    gulp.src(['app/styles/*.css', '!app/styles/styles.css'])
        .pipe(gulp.dest('dist/styles'));
});

//cleans our dist directory in case things got deleted
gulp.task('clean', function() {
  return gulp.src(['dist/*'], {read: false})
    .pipe(clean());
});

//this is our master task when you run `gulp` in CLI / Terminal
//this is the main watcher to use when in active development
//  this will:
//  startup the web server,
//  start up livereload
//  compress all scripts and SCSS files
gulp.task('default', ['connect', 'scripts', 'styles'], function() {
    //a list of watchers, so it will watch all of the following files waiting for changes
    gulp.watch('app/scripts/src/**', ['scripts']);
    gulp.watch('app/styles/scss/**', ['styles']);
    gulp.watch('app/images/**', ['images']);
    gulp.watch('app/*.html', ['html']);
});

//this is our deployment task, it will set everything for deployment-ready files
gulp.task('deploy', ['clean'], function () {
  gulp.start('scripts-deploy', 'styles-deploy', 'html-deploy', 'images-deploy');
});
<commit_msg>Update gulpfile to use the new del module for cleaning the dist folder<commit_after>//initialize all of our variables
var app, base, concat, directory, gulp, gutil, hostname, path, refresh, sass, uglify, imagemin, cache, minifyCSS, del, connect;

//load all of our dependencies
//add more here if you want to include more libraries
gulp        = require('gulp');
gutil       = require('gulp-util');
concat      = require('gulp-concat');
uglify      = require('gulp-uglify');
sass        = require('gulp-sass');
imagemin    = require('gulp-imagemin');
cache       = require('gulp-cache');
minifyCSS   = require('gulp-minify-css');
connect     = require('gulp-connect');
del         = require('del');

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

//compressing images & handle SVG files
gulp.task('images', function(tmp) {
    console.log(tmp);
    gulp.src(['app/images/*.jpg', 'app/images/*.png'])
        .pipe(imagemin({ optimizationLevel: 5, progressive: true, interlaced: true }));
});

//compressing images & handle SVG files
gulp.task('images-deploy', function() {
    gulp.src(['app/images/**/*'])
        .pipe(gulp.dest('dist/images'));
});

//compiling our Javascripts
gulp.task('scripts', function() {
    //this is where our dev JS scripts are
    return gulp.src('app/scripts/src/**/*.js')
                //this is the filename of the compressed version of our JS
               .pipe(concat('app.js'))
               //catch errors
               .on('error', gutil.log)
               //compress :D
               .pipe(uglify())
               //where we will store our finalized, compressed script
               .pipe(gulp.dest('app/scripts'))
               //notify LiveReload to refresh
               .pipe(connect.reload());
});

//compiling our Javascripts for deployment
gulp.task('scripts-deploy', function() {
    //this is where our dev JS scripts are
    return gulp.src('app/scripts/src/**/*.js')
                //this is the filename of the compressed version of our JS
               .pipe(concat('app.js'))
               //compress :D
               .pipe(uglify())
               //where we will store our finalized, compressed script
               .pipe(gulp.dest('dist/scripts'));
});

//compiling our SCSS files
gulp.task('styles', function() {
    //the initializer / master SCSS file, which will just be a file that imports everything
    return gulp.src('app/styles/scss/init.scss')
                //include SCSS and list every "include" folder
               .pipe(sass({
                      errLogToConsole: true,
                      includePaths: [
                          'app/styles/scss/'
                      ]
               }))
               //catch errors
               .on('error', gutil.log)
               //the final filename of our combined css file
               .pipe(concat('styles.css'))
               //where to save our final, compressed css file
               .pipe(gulp.dest('app/styles'))
               //notify LiveReload to refresh
               .pipe(connect.reload());
});

//compiling our SCSS files for deployment
gulp.task('styles-deploy', function() {
    //the initializer / master SCSS file, which will just be a file that imports everything
    return gulp.src('app/styles/scss/init.scss')
                //include SCSS includes folder
               .pipe(sass({
                      includePaths: [
                          'app/styles/scss',
                      ]
               }))
               //the final filename of our combined css file
               .pipe(concat('styles.css'))
               .pipe(minifyCSS())
               //where to save our final, compressed css file
               .pipe(gulp.dest('dist/styles'));
});

//basically just keeping an eye on all HTML files
gulp.task('html', function() {
    //watch any and all HTML files and refresh when something changes
    return gulp.src('app/*.html')
        .pipe(connect.reload())
       //catch errors
       .on('error', gutil.log);
});

//migrating over all HTML files for deployment
gulp.task('html-deploy', function() {
    //grab everything, which should include htaccess, robots, etc
    gulp.src('app/*')
        .pipe(gulp.dest('dist'));

    //grab any hidden files too
    gulp.src('app/.*')
        .pipe(gulp.dest('dist'));

    gulp.src('app/fonts/**/*')
        .pipe(gulp.dest('dist/fonts'));

    //grab all of the styles
    gulp.src(['app/styles/*.css', '!app/styles/styles.css'])
        .pipe(gulp.dest('dist/styles'));
});

//cleans our dist directory in case things got deleted
gulp.task('clean', function() {
    del('dist');
});

//this is our master task when you run `gulp` in CLI / Terminal
//this is the main watcher to use when in active development
//  this will:
//  startup the web server,
//  start up livereload
//  compress all scripts and SCSS files
gulp.task('default', ['connect', 'scripts', 'styles'], function() {
    //a list of watchers, so it will watch all of the following files waiting for changes
    gulp.watch('app/scripts/src/**', ['scripts']);
    gulp.watch('app/styles/scss/**', ['styles']);
    gulp.watch('app/images/**', ['images']);
    gulp.watch('app/*.html', ['html']);
});

//this is our deployment task, it will set everything for deployment-ready files
gulp.task('deploy', ['clean'], function () {
  gulp.start('scripts-deploy', 'styles-deploy', 'html-deploy', 'images-deploy');
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var ts = require('gulp-tsc');

gulp.task('browserify', function() {
    return browserify({
        entries: ['./src/browser.js']
    }).bundle().pipe(source('unitary.browser.js')).pipe(gulp.dest('./dist'));
});
gulp.task('compile', function() {
    return gulp.src('src/unitary.ts')
        .pipe(ts())
        .pipe(gulp.dest('dist'));
});
gulp.task('default', ['compile', 'browserify']);
<commit_msg>gulp compiles as sync now.<commit_after>var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var ts = require('gulp-tsc');

gulp.task('browserify', ['compile'], function() {
    return browserify({
        entries: ['./src/browser.js']
    }).bundle().pipe(source('unitary.browser.js')).pipe(gulp.dest('./dist'));
});
gulp.task('compile', function() {
    return gulp.src('src/unitary.ts')
        .pipe(ts())
        .pipe(gulp.dest('dist'));
});
gulp.task('default', ['browserify']);
<|endoftext|>


<commit_before>var gulp = require('gulp-help')(require('gulp'));
var zip = require('gulp-zip');
var gutil = require('gulp-util');
var rimraf = require('rimraf');
var path = require('path');
var extensionPath = path.resolve(__dirname, 'extension');
var browserify = require('browserify');
var transform = require('vinyl-transform');

gulp.task('default', ['build']);
gulp.task('build', 'Rebuild the extension files', ['extension-assets', 'extension-browserify']);

gulp.task('extension-browserify', 'Browserify the extension files', ['prepare'], function() {
  var browserified = transform(function(filename) {
    var b = browserify(filename);
    return b.bundle();
  });

  return gulp.src([
    './extension/src/index.js'
  ])
  .pipe(browserified)
  .pipe(gulp.dest('./extension/dist'));
});

gulp.task('extension-assets', 'Copy the extension source assets into the dist folder', ['prepare', 'chromex-assets'], function() {
  return gulp.src([
    './extension/src/*.png',
    './extension/src/*.svg',
    './extension/src/*.json'
  ])
  .pipe(gulp.dest('./extension/dist'));
});

gulp.task('chromex-assets', 'Assets required for the chromex code to work as expected', ['prepare'], function() {
  return gulp.src([
    './node_modules/chromex/scripts/*.js'
  ])
  .pipe(gulp.dest('./extension/dist/scripts'));
});

gulp.task('prepare', 'Prepare the build', ['clean'], function() {
});

gulp.task('clean', 'Clean the extension dist directory', function(cb) {
  rimraf(path.join(extensionPath, 'dist'), cb);
});

/*
gulp.task('serve', 'Serve the local files using a development server', function(cb) {
  var mount = st({
    path: process.cwd(),
    index: 'index.html',
    cache: false
  });

  http.createServer(mount).listen(port, function(err) {
    if (! err) {
      gutil.log('server running @ http://localhost:' + port + '/');
    }

    cb(err);
  });
});

gulp.task('package', 'Package for upload to build.rtc.io', function() {
  return gulp.src([
    './*',
    '!*.zip',
    'vendor/*',
    '!vendor/*.zip',
    'css/*',
    '!css/*.zip',
    'icons/*',
    '!icons/*.zip',
    '!gulpfile.js',
    '!package.json'
  ], { base: '.' })
  .pipe(zip('archive.zip'))
  .pipe(gulp.dest('.//'));
});

gulp.task('vendor', 'Rebuild vendor scripts from node package dependencies', [
  'vendor-rtc',
  'plugin-ios',
  'plugin-temasys'
]);

gulp.task('vendor-rtc', function() {
  return gulp
    .src('node_modules/rtc/dist/*')
    .pipe(gulp.dest('vendor/'));
});

gulp.task('plugin-ios', function() {
  return gulp
    .src('node_modules/rtc-plugin-nicta-ios/dist/*')
    .pipe(gulp.dest('vendor/'));
});

gulp.task('plugin-temasys', function() {
  return gulp
    .src('node_modules/rtc-plugin-temasys/dist/*')
    .pipe(gulp.dest('vendor/'));
});
*/
<commit_msg>add packaging step<commit_after>var gulp = require('gulp-help')(require('gulp'));
var zip = require('gulp-zip');
var gutil = require('gulp-util');
var rimraf = require('rimraf');
var path = require('path');
var extensionPath = path.resolve(__dirname, 'extension');
var browserify = require('browserify');
var transform = require('vinyl-transform');

gulp.task('default', ['build']);
gulp.task('build', 'Rebuild the extension files', ['extension-assets', 'extension-browserify']);

gulp.task('extension-browserify', 'Browserify the extension files', ['prepare'], function() {
  var browserified = transform(function(filename) {
    var b = browserify(filename);
    return b.bundle();
  });

  return gulp.src([
    './extension/src/index.js'
  ])
  .pipe(browserified)
  .pipe(gulp.dest('./extension/dist'));
});

gulp.task('extension-assets', 'Copy the extension source assets into the dist folder', ['prepare', 'chromex-assets'], function() {
  return gulp.src([
    './extension/src/*.png',
    './extension/src/*.svg',
    './extension/src/*.json'
  ])
  .pipe(gulp.dest('./extension/dist'));
});

gulp.task('chromex-assets', 'Assets required for the chromex code to work as expected', ['prepare'], function() {
  return gulp.src([
    './node_modules/chromex/scripts/*.js'
  ])
  .pipe(gulp.dest('./extension/dist/scripts'));
});

gulp.task('prepare', 'Prepare the build', ['clean'], function() {
});

gulp.task('clean', 'Clean the extension dist directory', function(cb) {
  rimraf(path.join(extensionPath, 'dist'), cb);
});

gulp.task('package', 'Package the extension for deployment', ['build'], function() {
  return gulp.src([
    './extension/dist/**',
  ], { base: './extension/dist' })
  .pipe(zip('extension-bundle.zip'))
  .pipe(gulp.dest('.//'));
});
<|endoftext|>


<commit_before>var gulp = require('gulp'),
    sass = require('gulp-sass'),
    autoprefixer = require('gulp-autoprefixer'),
    gutil = require('gulp-util'),
    browserSync = require('browser-sync').create(),
    browserify = require('browserify'),
    babelify = require('babelify'),
    watchify = require('watchify'),
    source = require('vinyl-source-stream'),
    notify = require('gulp-notify'),
    wiredep = require('wiredep'),
    postcss = require('gulp-postcss'),
    reporter = require('postcss-reporter'),
    syntax_scss = require('postcss-scss'),
    stylelint = require('stylelint'),
    imagemin = require('gulp-imagemin');

// Change the proxy property to suit your domain
gulp.task('browser-sync', function() {
  browserSync.init({
    proxy: 'boilerplate.dev',
    xip: true,
    online: true
  });
});

gulp.task('wiredep', function() {
  gulp.src('./_footer.php')
    .pipe(wiredep.stream())
    .pipe(gulp.dest('./'));
});

gulp.task('wiredep:watch', function() {
  gulp.watch('bower.json', ['wiredep']);
});

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

gulp.task('watch', ['styles:watch', 'scripts:watch', 'browser-sync', 'wiredep:watch'], function() {
      gulp.watch('**/*.php').on('change', browserSync.reload);
      gulp.watch('./assets/scripts/**/*.js').on('change', browserSync.reload);
});

/**
 * Handle errors
 * @see https://gist.github.com/wesbos/52b8fe7e972356e85b43
 * @return {void}
 */
function handleErrors() {
  var args = Array.prototype.slice.call(arguments);
  notify.onError({
    title: 'Compile Error',
    message: '<%= error.message %>'
  }).apply(this, args);
  this.emit('end'); // Keep gulp from hanging on this task
}

/**
 * Build scripts
 * @see https://gist.github.com/wesbos/52b8fe7e972356e85b43
 */
function buildScript(file, watch) {
  var props = {
    entries: ['./src/scripts/' + file],
    debug : true,
    transform:  [babelify]
  };

  // watchify() if watch requested, otherwise run browserify() once
  var bundler = watch ? watchify(browserify(props)) : browserify(props);

  function rebundle() {
    var stream = bundler.bundle(),
        fileName = file.split('.')[0];

    return stream
      .on('error', handleErrors)
      .pipe(source(fileName + '.bundle.js'))
      .pipe(notify({title: 'JS Compiled!', message: 'Yurt', icon: './src/icon.png'}))
      .pipe(gulp.dest('./assets/scripts/'));
  }

  // listen for an update and run rebundle
  bundler.on('update', function() {
    rebundle();
    gutil.log('Rebundle...');
  });

  // run it once the first time buildScript is called
  return rebundle();
}

/**
 * Build our main.js file
 * @param  {string} 'scripts'
 * @param  {function} callback
 */
gulp.task('scripts', function() {
  return buildScript('main.js', false);
});

/**
 * Watch and build our main.js file
 * @param  {string} 'scripts:watch'
 * @param  {function} callback
 */
gulp.task('scripts:watch', function() {
  return buildScript('main.js', true);
});

/**
 * Compile styles
 * @param  {string} 'styles'
 * @param  {function} callback for the task
 */
gulp.task('styles', function() {
  return gulp.src('./src/scss/main.scss')
    .pipe(sass().on('error', handleErrors))
    .pipe(autoprefixer({
        browsers: ['last 5 versions']
    }))
    .pipe(notify({title: 'Styles Compiled!', message: 'Good hustle', icon: './src/icon.png'}))
    .pipe(gulp.dest('./assets/css/'))
    .pipe(browserSync.stream());
});

var processors = [
  stylelint(),
  reporter({
    clearMessages: true,
    throwError: true
  })
];

gulp.task('lint-styles', function() {
  return gulp.src('src/scss/**/*.scss')
            .pipe(postcss(processors, {syntax: syntax_scss}));
});

/**
 * Watch styles and run the 'styles' task on change
 * @param  {string} 'styles:watch'
 * @param  {function} callback
 */
gulp.task('styles:watch', function() {
  gulp.watch('src/scss/**/*.scss', ['styles']);
});
<commit_msg>Removes stylelint for now<commit_after>var gulp = require('gulp'),
    sass = require('gulp-sass'),
    autoprefixer = require('gulp-autoprefixer'),
    gutil = require('gulp-util'),
    browserSync = require('browser-sync').create(),
    browserify = require('browserify'),
    babelify = require('babelify'),
    watchify = require('watchify'),
    source = require('vinyl-source-stream'),
    notify = require('gulp-notify'),
    wiredep = require('wiredep'),
    imagemin = require('gulp-imagemin');

// Change the proxy property to suit your domain
gulp.task('browser-sync', function() {
  browserSync.init({
    proxy: 'boilerplate.dev',
    xip: true,
    online: true
  });
});

gulp.task('wiredep', function() {
  gulp.src('./_footer.php')
    .pipe(wiredep.stream())
    .pipe(gulp.dest('./'));
});

gulp.task('wiredep:watch', function() {
  gulp.watch('bower.json', ['wiredep']);
});

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

gulp.task('watch', ['styles:watch', 'scripts:watch', 'browser-sync', 'wiredep:watch'], function() {
      gulp.watch('**/*.php').on('change', browserSync.reload);
      gulp.watch('./assets/scripts/**/*.js').on('change', browserSync.reload);
});

/**
 * Handle errors
 * @see https://gist.github.com/wesbos/52b8fe7e972356e85b43
 * @return {void}
 */
function handleErrors() {
  var args = Array.prototype.slice.call(arguments);
  notify.onError({
    title: 'Compile Error',
    message: '<%= error.message %>'
  }).apply(this, args);
  this.emit('end'); // Keep gulp from hanging on this task
}

/**
 * Build scripts
 * @see https://gist.github.com/wesbos/52b8fe7e972356e85b43
 */
function buildScript(file, watch) {
  var props = {
    entries: ['./src/scripts/' + file],
    debug : true,
    transform:  [babelify]
  };

  // watchify() if watch requested, otherwise run browserify() once
  var bundler = watch ? watchify(browserify(props)) : browserify(props);

  function rebundle() {
    var stream = bundler.bundle(),
        fileName = file.split('.')[0];

    return stream
      .on('error', handleErrors)
      .pipe(source(fileName + '.bundle.js'))
      .pipe(notify({title: 'JS Compiled!', message: 'Yurt', icon: './src/icon.png'}))
      .pipe(gulp.dest('./assets/scripts/'));
  }

  // listen for an update and run rebundle
  bundler.on('update', function() {
    rebundle();
    gutil.log('Rebundle...');
  });

  // run it once the first time buildScript is called
  return rebundle();
}

/**
 * Build our main.js file
 * @param  {string} 'scripts'
 * @param  {function} callback
 */
gulp.task('scripts', function() {
  return buildScript('main.js', false);
});

/**
 * Watch and build our main.js file
 * @param  {string} 'scripts:watch'
 * @param  {function} callback
 */
gulp.task('scripts:watch', function() {
  return buildScript('main.js', true);
});

/**
 * Compile styles
 * @param  {string} 'styles'
 * @param  {function} callback for the task
 */
gulp.task('styles', function() {
  return gulp.src('./src/scss/main.scss')
    .pipe(sass().on('error', handleErrors))
    .pipe(autoprefixer({
        browsers: ['last 5 versions']
    }))
    .pipe(notify({title: 'Styles Compiled!', message: 'Good hustle', icon: './src/icon.png'}))
    .pipe(gulp.dest('./assets/css/'))
    .pipe(browserSync.stream());
});

/**
 * Watch styles and run the 'styles' task on change
 * @param  {string} 'styles:watch'
 * @param  {function} callback
 */
gulp.task('styles:watch', function() {
  gulp.watch('src/scss/**/*.scss', ['styles']);
});
<|endoftext|>


<commit_before>var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var replace = require('gulp-replace');
var rename = require('gulp-rename');
var karma = require('karma').server;
var argv = require('yargs').argv;

var paths = {
  sass: [
    './www/components/**/*.scss',
    './www/views/**/*.scss',
    './www/app.scss'
  ]
};

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

gulp.task('sass', function(done) {
  gulp.src('./www/app.scss')
    .pipe(sourcemaps.init())
    .pipe(sass())
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('./www/'))
    .on('end', done);
});

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

gulp.task('test', function(done) {
  gulp.src('./www/config.js')
    .pipe(replace('jspm_packages', 'www/jspm_packages'))
    .pipe(rename('config-test.js'))
    .pipe(gulp.dest('./www/'));

  karma.start({
    configFile: __dirname + '/karma.conf.js',
    singleRun: argv.prod
  }, done);
});<commit_msg>Fixed karma not exiting properly on ctrl-c<commit_after>var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var replace = require('gulp-replace');
var rename = require('gulp-rename');
var karma = require('karma').server;
var argv = require('yargs').argv;

var paths = {
  sass: [
    './www/components/**/*.scss',
    './www/views/**/*.scss',
    './www/app.scss'
  ]
};

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

gulp.task('sass', function(done) {
  gulp.src('./www/app.scss')
    .pipe(sourcemaps.init())
    .pipe(sass())
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('./www/'))
    .on('end', done);
});

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

gulp.task('test', function(done) {
  gulp.src('./www/config.js')
    .pipe(replace('jspm_packages', 'www/jspm_packages'))
    .pipe(rename('config-test.js'))
    .pipe(gulp.dest('./www/'));

  karma.start({
    configFile: __dirname + '/karma.conf.js',
    singleRun: argv.prod
  }, argv.prod ? done : undefined);
});<|endoftext|>


<commit_before>'use strict';

//=============================================
//            DECLARE CORE VARIABLES
//=============================================

/**
 * Load required core dependencies. These are installed based on the versions listed
 * in 'package.json' when you do 'npm install' in this directory.
 */
var fs          = require('fs');
var pkg         = require('./package.json');
var open        = require("open");
var path        = require('path');
var argv        = require('minimist')(process.argv.slice(2));
var gulp        = require('gulp');
var karma       = require('karma').server;
var semver      = require('semver');
var browser     = require('tiny-lr')();
var connect     = require('gulp-connect');
var wiredep     = require('wiredep').stream;
var changelog   = require('conventional-changelog');
var runSequence = require('run-sequence');

//=============================================
//            DECLARE GULP VARIABLES
//=============================================

/**
 * Load required Gulp tasks. These are installed based on the versions listed
 * in 'package.json' when you do 'npm install' in this directory.
 */
var size                 = require('gulp-size');
var gzip                 = require('gulp-gzip');
var bump                 = require('gulp-bump');
var help                 = require('gulp-help')(gulp);
var exec                 = require('gulp-exec');
var gutil                = require('gulp-util');
var bower                = require('gulp-bower');
var watch                = require('gulp-watch');
var clean                = require('gulp-clean');
var gulpif               = require('gulp-if');
var jshint               = require('gulp-jshint');
var header               = require('gulp-header');
var uglify               = require('gulp-uglify');
var rename               = require('gulp-rename');
var concat               = require('gulp-concat');
var refresh              = require('gulp-livereload');
var sourcemaps           = require('gulp-sourcemaps');
var ngAnnotate           = require('gulp-ng-annotate');
var coverageEnforcer     = require("gulp-istanbul-enforcer");

//=============================================
//            DECLARE CONSTANTS
//=============================================

/**
 * Declare constants that are use in gulpfile.js or angular app
 */
var COLORS               = gutil.colors;
var DEMO_PORT            = 9000;
var LIVERELOAD_PORT      = 35729;

//=============================================
//            DECLARE VARIABLES
//=============================================
/**
 * Declare variables that are use in gulpfile.js
 */
var hasGitChanges   = '';
var isWatching      = false;

//=============================================
//            DECLARE PATHS
//=============================================

var paths = {
    gulpfile:       'gulpfile.js',
    dist:           'dist/',
    src:            'src/*.js',
    vendor:         'bower_components/',
    html:           'demo/*.html',
    tmp:            '.tmp',
    testReports:    '.tmp/test-reports/coverage/'
};

//=============================================
//            DECLARE BANNER DETAILS
//=============================================

/**
 * The banner is the comment that is placed at the top of our compiled
 * source files. It is first processed as a Grunt template, where the `<%=`
 * pairs are evaluated based on this very configuration object.
 */
var banner = gutil.template('/**\n' +
    ' * <%= pkg.description %>\n' +
    ' * @version v<%= pkg.version %> - <%= today %>\n' +
    ' * @link <%= pkg.homepage %>\n' +
    ' * @author <%= pkg.author.name %>\n' +
    ' * @copyright <%= year %>(c) <%= pkg.author.name %>\n' +
    ' * @license <%= pkg.licenses.type %>, <%= pkg.licenses.url %>\n' +
    ' */\n', {file: '', pkg: pkg, today: new Date().toISOString().substr(0, 10), year: new Date().toISOString().substr(0, 4)});

//=============================================
//               SUB TASKS
//=============================================

gulp.task('clean', 'Delete \'dist\' directory', function () {
    return gulp.src([paths.dist, paths.tmp], {read: false})
        .pipe(clean());
});

gulp.task('copy', 'Copy no-minified source files into \'dist\' folder.', function () {
    return gulp.src(paths.src)
        .pipe(concat(pkg.name + '.js'))
        .pipe(header(banner, { pkg : pkg, date: new Date }))
        .pipe(gulp.dest(paths.dist));
});

gulp.task('bower', 'Install all bower dependencies specify in bower.json from bower repository', function () {
    return bower();
});

gulp.task('bower-install', 'Does the same as \'bower\' task but also inject bower components to index.html', ['bower'], function () {
    return gulp.src(paths.html)
        .pipe(wiredep({
            directory: paths.vendor
        }))
        .pipe(gulp.dest('./demo'))
        .pipe(size());
});

gulp.task('jshint', 'Hint src JavaScripts files', function () {
    return gulp.src(paths.src)
        .pipe(jshint('.jshintrc'))
        .pipe(jshint.reporter('jshint-stylish'))
        .pipe(gulpif(!isWatching, jshint.reporter('fail')))
        .pipe(gulpif(isWatching, refresh(browser)))
        .pipe(size());
});

gulp.task('compress', 'Compress js files to min.js', function() {
    return gulp.src(paths.src)
        .pipe(sourcemaps.init())
        .pipe(concat(pkg.name + '.js'))
        .pipe(ngAnnotate())
        .pipe(uglify())
        .pipe(sourcemaps.write())
        .pipe(header(banner))
        .pipe(rename({suffix: '.min'}))
        .pipe(gulp.dest(paths.dist))
        .pipe(size())
        .on('error', function (error) {
            gutil.log(COLORS.red('Error: compress failed '  + error));
            return process.exit(1);
        });
});

gulp.task('compress:gzip', 'Compress js files to min.js.gz', function() {
    return gulp.src(paths.src)
        .pipe(concat(pkg.name + '.js'))
        .pipe(ngAnnotate())
        .pipe(uglify())
        .pipe(header(banner))
        .pipe(rename({suffix: '.min'}))
        .pipe(gulp.dest(paths.dist))
        .pipe(gzip())
        .pipe(gulp.dest(paths.dist))
        .pipe(size())
        .on('error', function (error) {
            gutil.log(COLORS.red('Error: compress:zip failed ' + error));
            return process.exit(1);
        });
});

gulp.task('watch', 'Watch files for changes', function () {

    // set to 'true' to avoid process exit on error for jshint
    isWatching = true;

    // Listen on port 35729
    browser.listen(LIVERELOAD_PORT, function (err) {
        if (err) {
            return console.log(err);
        }

        gulp.watch([
            paths.html
        ], function (event) {
            return gulp.src(event.path)
                .pipe(refresh(browser));
        });

        // Watch js files
        gulp.watch(paths.src, ['jshint']);

        // Watch bower file
        gulp.watch('bower.json', ['bower-install']);
    });

});

gulp.task('karma', 'Run karma unit tests', ['bower-install'], function (cb) {
    // remove 'coverage' directory before each test
    gulp.src(paths.testReports, {read: false})
        .pipe(clean())
        .on('finish', function() {
            // run the karma test
            karma.start({
                configFile: path.join(__dirname, 'karma.conf.js'),
                browsers: ['PhantomJS']
            }, function(code) {
                // make sure failed karma tests cause gulp to exit non-zero
                if(code === 1) {
                    gutil.log(COLORS.red('Error: unit test failed '));
                    process.exit(1);
                }
                cb();
            });
        });
});

gulp.task('check', 'Check if there are any changes to commit', function (cb) {
    require('child_process').exec('git status --porcelain', function (err, stdout) {
        hasGitChanges = stdout;
        cb(err);
    });
});

//=============================================
//                MAIN TASKS
//=============================================

/**
 * The demo web server.
 */
gulp.task('serve', 'Run the demo web server', ['bower-install', 'watch'], function() {
    connect.server({
        root: ['./', 'demo'],
        port: DEMO_PORT,
        livereload: false
    });
    if(gutil.env.open) {
        gutil.log('Opening dev server URL in browser');
        open('http://localhost:' + DEMO_PORT);
    } else {
        gutil.log(COLORS.yellow('Hint: Run with --open to automatically open URL on startup'));
    }
});

/**
 * Run unit test and coverage.
 */
gulp.task('test', 'Run unit tests and coverage', ['karma'], function () {
    var options = {
        thresholds : {
            statements : 95,
            branches : 90,
            lines : 95,
            functions : 95
        },
        coverageDirectory: paths.testReports,
        rootDirectory : paths.tmp // keep root `.tmp` so enforce plugin is not searching in other directories
    };
    return gulp.src('.')
//        .pipe(coverageEnforcer(options))
        .on('error', function(error) {
            gutil.log(error.toString());
            process.exit(1);
        });
});

/**
 * The 'build' task gets app ready for deployment by
 * minifying etc.
 */
gulp.task('build', 'Build dist files', function (cb) {
    runSequence(
        ['clean', 'jshint', 'bower-install'],
        'test',
        ['compress', 'compress:gzip', 'copy'],
        cb);
});

/**
 * Bump version number in package.json & bower.json.
 */
gulp.task('bump', 'Bump version number in package.json & bower.json', ['jshint'], function () {
    var HAS_REQUIRED_ATTRIBUTE = !!argv.type ? !!argv.type.match(new RegExp(/major|minor|patch/)) : false;

    if (!HAS_REQUIRED_ATTRIBUTE) {
        gutil.log(COLORS.red('Error: Required bump \'type\' is missing! Usage: gulp bump --type=(major|minor|patch)'));
        return process.exit(1);
    }

    if (!semver.valid(pkg.version)) {
        gutil.log(COLORS.red('Error: Invalid version number - ' + pkg.version));
        return process.exit(1);
    }

    return gulp.src(['package.json', 'bower.json'])
        .pipe(bump({type: argv.type}))
        .pipe(gulp.dest('./'));
});

/**
 * Generate changelog.
 */
gulp.task('changelog', 'Generate changelog', function(callback) {
    changelog({
        version: pkg.version,
        repository: 'https://github.com/martinmicunda/' + pkg.name
    }, function(err, data) {
        if (err) {
            gutil.log(COLORS.red('Error: Failed to generate changelog ' + err));
            return process.exit(1);
        }
        fs.writeFileSync('CHANGELOG.md', data);
        callback()
    });
});

/**
 * The 'release' task push package.json and CHANGELOG.md to GitHub.
 */
gulp.task('release', 'Release bumped version number to GitHub repo', ['check'], function () {
    if (!semver.valid(pkg.version)) {
        gutil.log(COLORS.red('Error: Invalid version number - ' + pkg.version + '. Please fix the the version number in package.json and run \'gulp publish\' command again.'));
        return process.exit(1);
    }

    if (hasGitChanges === '') {
        gutil.log(COLORS.red('Error: No changes detected in this repo. Aborting release.'));
        return process.exit(1);
    }

    gutil.log(COLORS.blue('Pushing to GitHub ...'));
    var commitMsg = 'chore(release): v' + pkg.version;
    return gulp.src('package.json')
        .pipe(exec('git add dist CHANGELOG.md package.json bower.json'))
        .pipe(exec('git commit -m "' + commitMsg + '" --no-verify'))
        .pipe(exec('git push origin master'));
});
<commit_msg>edit gulpfile<commit_after>'use strict';

//=============================================
//            DECLARE CORE VARIABLES
//=============================================

/**
 * Load required core dependencies. These are installed based on the versions listed
 * in 'package.json' when you do 'npm install' in this directory.
 */
var fs          = require('fs');
var pkg         = require('./package.json');
var open        = require("open");
var path        = require('path');
var argv        = require('minimist')(process.argv.slice(2));
var gulp        = require('gulp');
var karma       = require('karma').server;
var semver      = require('semver');
var browser     = require('tiny-lr')();
var connect     = require('gulp-connect');
var wiredep     = require('wiredep').stream;
var changelog   = require('conventional-changelog');
var runSequence = require('run-sequence');

//=============================================
//            DECLARE GULP VARIABLES
//=============================================

/**
 * Load required Gulp tasks. These are installed based on the versions listed
 * in 'package.json' when you do 'npm install' in this directory.
 */
var size                 = require('gulp-size');
var gzip                 = require('gulp-gzip');
var bump                 = require('gulp-bump');
var help                 = require('gulp-help')(gulp);
var exec                 = require('gulp-exec');
var gutil                = require('gulp-util');
var bower                = require('gulp-bower');
var watch                = require('gulp-watch');
var clean                = require('gulp-clean');
var gulpif               = require('gulp-if');
var jshint               = require('gulp-jshint');
var header               = require('gulp-header');
var uglify               = require('gulp-uglify');
var rename               = require('gulp-rename');
var concat               = require('gulp-concat');
var refresh              = require('gulp-livereload');
var sourcemaps           = require('gulp-sourcemaps');
var ngAnnotate           = require('gulp-ng-annotate');
var coverageEnforcer     = require("gulp-istanbul-enforcer");

//=============================================
//            DECLARE CONSTANTS
//=============================================

/**
 * Declare constants that are use in gulpfile.js or angular app
 */
var COLORS               = gutil.colors;
var DEMO_PORT            = 9000;
var LIVERELOAD_PORT      = 35729;

//=============================================
//            DECLARE VARIABLES
//=============================================
/**
 * Declare variables that are use in gulpfile.js
 */
var hasGitChanges   = '';
var isWatching      = false;

//=============================================
//            DECLARE PATHS
//=============================================

var paths = {
    gulpfile:       'gulpfile.js',
    dist:           'dist/',
    src:            'src/*.js',
    vendor:         'bower_components/',
    html:           'demo/*.html',
    tmp:            '.tmp',
    testReports:    '.tmp/test-reports/coverage/'
};

//=============================================
//            DECLARE BANNER DETAILS
//=============================================

/**
 * The banner is the comment that is placed at the top of our compiled
 * source files. It is first processed as a Grunt template, where the `<%=`
 * pairs are evaluated based on this very configuration object.
 */
var banner = gutil.template('/**\n' +
    ' * <%= pkg.description %>\n' +
    ' * @version v<%= pkg.version %> - <%= today %>\n' +
    ' * @link <%= pkg.homepage %>\n' +
    ' * @author <%= pkg.author.name %>\n' +
    ' * @copyright <%= year %>(c) <%= pkg.author.name %>\n' +
    ' * @license <%= pkg.licenses.type %>, <%= pkg.licenses.url %>\n' +
    ' */\n', {file: '', pkg: pkg, today: new Date().toISOString().substr(0, 10), year: new Date().toISOString().substr(0, 4)});

//=============================================
//               SUB TASKS
//=============================================

gulp.task('clean', 'Delete \'dist\' directory', function () {
    return gulp.src([paths.dist, paths.tmp], {read: false})
        .pipe(clean());
});

gulp.task('copy', 'Copy no-minified source files into \'dist\' folder.', function () {
    return gulp.src(paths.src)
        .pipe(concat(pkg.name + '.js'))
        .pipe(header(banner, { pkg : pkg, date: new Date }))
        .pipe(gulp.dest(paths.dist));
});

gulp.task('bower', 'Install all bower dependencies specify in bower.json from bower repository', function () {
    return bower();
});

gulp.task('bower-install', 'Does the same as \'bower\' task but also inject bower components to index.html', ['bower'], function () {
    return gulp.src(paths.html)
        .pipe(wiredep({
            directory: paths.vendor
        }))
        .pipe(gulp.dest('./demo'))
        .pipe(size());
});

gulp.task('jshint', 'Hint src JavaScripts files', function () {
    return gulp.src(paths.src)
        .pipe(jshint('.jshintrc'))
        .pipe(jshint.reporter('jshint-stylish'))
        .pipe(gulpif(!isWatching, jshint.reporter('fail')))
        .pipe(gulpif(isWatching, refresh(browser)))
        .pipe(size());
});

gulp.task('compress', 'Compress js files to min.js', function() {
    return gulp.src(paths.src)
        .pipe(sourcemaps.init())
        .pipe(concat(pkg.name + '.js'))
        .pipe(ngAnnotate())
        .pipe(uglify())
        .pipe(sourcemaps.write())
        .pipe(header(banner))
        .pipe(rename({suffix: '.min'}))
        .pipe(gulp.dest(paths.dist))
        .pipe(size())
        .on('error', function (error) {
            gutil.log(COLORS.red('Error: compress failed '  + error));
            return process.exit(1);
        });
});

gulp.task('compress:gzip', 'Compress js files to min.js.gz', function() {
    return gulp.src(paths.src)
        .pipe(concat(pkg.name + '.js'))
        .pipe(ngAnnotate())
        .pipe(uglify())
        .pipe(header(banner))
        .pipe(rename({suffix: '.min'}))
        .pipe(gulp.dest(paths.dist))
        .pipe(gzip())
        .pipe(gulp.dest(paths.dist))
        .pipe(size())
        .on('error', function (error) {
            gutil.log(COLORS.red('Error: compress:zip failed ' + error));
            return process.exit(1);
        });
});

gulp.task('watch', 'Watch files for changes', function () {

    // set to 'true' to avoid process exit on error for jshint
    isWatching = true;

    // Listen on port 35729
    browser.listen(LIVERELOAD_PORT, function (err) {
        if (err) {
            return console.log(err);
        }

        gulp.watch([
            paths.html
        ], function (event) {
            return gulp.src(event.path)
                .pipe(refresh(browser));
        });

        // Watch js files
        gulp.watch(paths.src, ['jshint']);

        // Watch bower file
        gulp.watch('bower.json', ['bower-install']);
    });

});

gulp.task('karma', 'Run karma unit tests', ['bower-install'], function (cb) {
    // remove 'coverage' directory before each test
    gulp.src(paths.testReports, {read: false})
        .pipe(clean())
        .on('finish', function() {
            // run the karma test
            karma.start({
                configFile: path.join(__dirname, 'karma.conf.js'),
                browsers: ['PhantomJS']
            }, function(code) {
                // make sure failed karma tests cause gulp to exit non-zero
                if(code === 1) {
                    gutil.log(COLORS.red('Error: unit test failed '));
                    process.exit(1);
                }
                cb();
            });
        });
});

gulp.task('check', 'Check if there are any changes to commit', function (cb) {
    require('child_process').exec('git status --porcelain', function (err, stdout) {
        hasGitChanges = stdout;
        cb(err);
    });
});

//=============================================
//                MAIN TASKS
//=============================================

/**
 * The demo web server.
 */
gulp.task('serve', 'Run the demo web server', ['bower-install', 'watch'], function() {
    connect.server({
        root: ['./', 'demo'],
        port: DEMO_PORT,
        livereload: false
    });
    if(gutil.env.open) {
        gutil.log('Opening dev server URL in browser');
        open('http://localhost:' + DEMO_PORT);
    } else {
        gutil.log(COLORS.yellow('Hint: Run with --open to automatically open URL on startup'));
    }
});

/**
 * Run unit test and coverage.
 */
gulp.task('test', 'Run unit tests and coverage', ['karma'], function () {
    var options = {
        thresholds : {
            statements : 95,
            branches : 90,
            lines : 95,
            functions : 95
        },
        coverageDirectory: paths.testReports,
        rootDirectory : paths.tmp // keep root `.tmp` so enforce plugin is not searching in other directories
    };
    return gulp.src('.')
//        .pipe(coverageEnforcer(options))
        .on('error', function(error) {
            gutil.log(error.toString());
            process.exit(1);
        });
});

/**
 * The 'build' task gets app ready for deployment by
 * minifying etc.
 */
gulp.task('build', 'Build dist files', function (cb) {
    runSequence(
        ['clean', 'jshint', 'bower-install'],
        'test',
        ['compress', 'compress:gzip', 'copy'],
        cb);
});

/**
 * Bump version number in package.json & bower.json.
 */
gulp.task('bump', 'Bump version number in package.json & bower.json', ['jshint'], function () {
    var HAS_REQUIRED_ATTRIBUTE = !!argv.type ? !!argv.type.match(new RegExp(/major|minor|patch/)) : false;

    if (!HAS_REQUIRED_ATTRIBUTE) {
        gutil.log(COLORS.red('Error: Required bump \'type\' is missing! Usage: gulp bump --type=(major|minor|patch)'));
        return process.exit(1);
    }

    if (!semver.valid(pkg.version)) {
        gutil.log(COLORS.red('Error: Invalid version number - ' + pkg.version));
        return process.exit(1);
    }

    return gulp.src(['package.json', 'bower.json'])
        .pipe(bump({type: argv.type}))
        .pipe(gulp.dest('./'));
});

/**
 * Generate changelog.
 */
gulp.task('changelog', 'Generate changelog', function(callback) {
    changelog({
        version: pkg.version,
        repository: 'https://github.com/martinmicunda/' + pkg.name
    }, function(err, data) {
        if (err) {
            gutil.log(COLORS.red('Error: Failed to generate changelog ' + err));
            return process.exit(1);
        }
        fs.writeFileSync('CHANGELOG.md', data, callback());
    });
});

/**
 * The 'release' task push package.json and CHANGELOG.md to GitHub.
 */
gulp.task('release', 'Release bumped version number to GitHub repo', ['check'], function () {
    if (!semver.valid(pkg.version)) {
        gutil.log(COLORS.red('Error: Invalid version number - ' + pkg.version + '. Please fix the the version number in package.json and run \'gulp publish\' command again.'));
        return process.exit(1);
    }

    if (hasGitChanges === '') {
        gutil.log(COLORS.red('Error: No changes detected in this repo. Aborting release.'));
        return process.exit(1);
    }

    gutil.log(COLORS.blue('Pushing to GitHub ...'));
    var commitMsg = 'chore(release): v' + pkg.version;
    return gulp.src('package.json')
        .pipe(exec('git add dist CHANGELOG.md package.json bower.json'))
        .pipe(exec('git commit -m "' + commitMsg + '" --no-verify'))
        .pipe(exec('git push origin master'));
});
<|endoftext|>


<commit_before>var gulp         = require('gulp'),
    shell        = require('gulp-shell'),
    postcss      = require('gulp-postcss'),
    atImport     = require('postcss-import'),
    cssnext      = require('postcss-cssnext'),
    cssnano      = require('gulp-cssnano'),
    autoprefixer = require('gulp-autoprefixer'),
    htmlmin      = require('gulp-htmlmin'),
  /*svgmin       = require('gulp-svgmin'),*/
    gzip         = require('gulp-gzip'),
    browserSync  = require('browser-sync').create(),
    reload       = browserSync.reload;

var processors = [
  atImport(),
  cssnext({
    'browsers': ['last 2 versions'],
    'features': {
      'customProperties': {
        preserve: true,
        appendVariables: true
      },
      'colorFunction': true,
      'customSelectors': true,
      'sourcemap': true,
      'rem': false
    }
  })
];

// styles
gulp.task('styles', function() {
  return gulp.src('_assets/src/style.css')
    .pipe(postcss(processors))
    .pipe(cssnano({discardComments: {removeAll: true}}))
    .pipe(gulp.dest('_assets/css'));
});

// styles > buildWatch
gulp.task('buildWatch', ['styles'], shell.task(
  'bundle exec jekyll build --watch'
));

// serve
gulp.task('serve', function() {
  browserSync.init({
    server: {
      baseDir: '_site/'
    },
    notify: false
  });
  gulp.watch('_assets/src/*.css', ['styles']);
  gulp.watch('_assets/css/style.css').on('change', reload);
  gulp.watch('_site/**/*.*').on('change', reload);
});

// styles > buildWatch, serve
gulp.task('default', ['buildWatch', 'serve']);

// PRODUCTION TASKS / PRODUCTION TASKS / PRODUCTION TASKS / PRODUCTION TASKS /
// TASKS / PRODUCTION TASKS / PRODUCTION TASKS / PRODUCTION TASKS / PRODUCTION
// PRODUCTION TASKS / PRODUCTION TASKS / PRODUCTION TASKS / PRODUCTION TASKS /
// TASKS / PRODUCTION TASKS / PRODUCTION TASKS / PRODUCTION TASKS / PRODUCTION

var path = '_site';

// styles > build
gulp.task('build', ['styles'], shell.task(
  // 'bundle exec jekyll build --destination ' + path
  'bundle exec jekyll build'
));

// styles > build > minify
gulp.task('minify', ['build'], function() {
  return gulp.src(path + '/**/*.html')
    .pipe(htmlmin({
      collapseWhitespace: true,
      minifyJS: true,
      removeComments: true
    }))
    .pipe(gulp.dest(path));
});

// styles > build > minify > compress
gulp.task('compress', ['minify'], function () {
  return gulp.src(path + '/**/*.html')
    .pipe(gzip())
    .pipe(gulp.dest(path));
});

// styles > build > minify > compress > deploy
gulp.task('deploy', ['compress'], shell.task(
  'cd _site; git add -A; git commit -S -m "Deploy"; git push live master'
));
<commit_msg>Remove assets folder on deploy<commit_after>var gulp         = require('gulp'),
    shell        = require('gulp-shell'),
    postcss      = require('gulp-postcss'),
    atImport     = require('postcss-import'),
    cssnext      = require('postcss-cssnext'),
    cssnano      = require('gulp-cssnano'),
    autoprefixer = require('gulp-autoprefixer'),
    htmlmin      = require('gulp-htmlmin'),
  /*svgmin       = require('gulp-svgmin'),*/
    gzip         = require('gulp-gzip'),
    browserSync  = require('browser-sync').create(),
    reload       = browserSync.reload;

var processors = [
  atImport(),
  cssnext({
    'browsers': ['last 2 versions'],
    'features': {
      'customProperties': {
        preserve: true,
        appendVariables: true
      },
      'colorFunction': true,
      'customSelectors': true,
      'sourcemap': true,
      'rem': false
    }
  })
];

// styles
gulp.task('styles', function() {
  return gulp.src('_assets/src/style.css')
    .pipe(postcss(processors))
    .pipe(cssnano({discardComments: {removeAll: true}}))
    .pipe(gulp.dest('_assets/css'));
});

// styles > buildWatch
gulp.task('buildWatch', ['styles'], shell.task(
  'bundle exec jekyll build --watch'
));

// serve
gulp.task('serve', function() {
  browserSync.init({
    server: {
      baseDir: '_site/'
    },
    notify: false
  });
  gulp.watch('_assets/src/*.css', ['styles']);
  gulp.watch('_assets/css/style.css').on('change', reload);
  gulp.watch('_site/**/*.*').on('change', reload);
});

// styles > buildWatch, serve
gulp.task('default', ['buildWatch', 'serve']);

// PRODUCTION TASKS / PRODUCTION TASKS / PRODUCTION TASKS / PRODUCTION TASKS /
// TASKS / PRODUCTION TASKS / PRODUCTION TASKS / PRODUCTION TASKS / PRODUCTION
// PRODUCTION TASKS / PRODUCTION TASKS / PRODUCTION TASKS / PRODUCTION TASKS /
// TASKS / PRODUCTION TASKS / PRODUCTION TASKS / PRODUCTION TASKS / PRODUCTION

var path = '_site';

// styles > build
gulp.task('build', ['styles'], shell.task(
  // 'bundle exec jekyll build --destination ' + path
  'bundle exec jekyll build'
));

// styles > build > minify
gulp.task('minify', ['build'], function() {
  return gulp.src(path + '/**/*.html')
    .pipe(htmlmin({
      collapseWhitespace: true,
      minifyJS: true,
      removeComments: true
    }))
    .pipe(gulp.dest(path));
});

// styles > build > minify > compress
gulp.task('compress', ['minify'], function () {
  return gulp.src(path + '/**/*.html')
    .pipe(gzip())
    .pipe(gulp.dest(path));
});

// styles > build > minify > compress > deploy
gulp.task('deploy', ['compress'], shell.task(
  'cd _site; rm -rf assets; git add -A; git commit -S -m "Deploy"; git push live master'
));
<|endoftext|>


<commit_before>/*eslint-env node */

var gulp = require('gulp'),
	sass = require('gulp-sass'),
	autoprefixer = require('gulp-autoprefixer'),
	browserSync = require('browser-sync').create(),
	eslint = require('gulp-eslint'),
	jasmine = require('gulp-jasmine-phantom'),
	inject = require('gulp-inject'),
	replace = require('gulp-replace'),
	concat = require('gulp-concat'),
	uglify = require('gulp-uglify'),
	angularFilesort = require('gulp-angular-filesort');

gulp.task('default', ['copy-js-dev', 'copy-html', 'copy-index-dev', 'copy-images', 'styles', 'fonts', 'lint'], function() {
	gulp.watch('app/assets/sass/**/*.scss', ['styles']);
	gulp.watch(['app/app.js', 'app/**/*.js'], ['lint', 'copy-js-dev']);
	gulp.watch('app/*/**/*.html', ['copy-html']);
	gulp.watch('app/index.html', ['copy-index-dev']);
	gulp.watch('dist/**/*.html').on('change', browserSync.reload);

	browserSync.init({
		server: 'dist',
	});
});

// Build app to app/dist in production-ready state
gulp.task('dist', ['js-dist', 'copy-html', 'copy-index', 'copy-images', 'fonts', 'styles']);

// Concatenate and uglify app JS; place in dist/js
gulp.task('js-dist', ['copy-js'], function() {
	gulp.src('app/**/*.js')
		.pipe(concat('eventplanner.js'))
		.pipe(uglify())
		.pipe(gulp.dest('dist/js'));
});

// Run ESLint on any changes to app JS
gulp.task('lint', function() {
	return gulp.src('app/**/*.js')
		.pipe(eslint())
		.pipe(eslint.format())
		.pipe(eslint.failOnError());
});

// Inject locally-hosted third-party JS (e.g. Angular) into index.html
gulp.task('copy-index-dev', ['copy-js-dev'], function() {
	gulp.src('app/index.html')
		.pipe(replace(/<!-- dev_only ([\s\S]*?)-->/g, '$1'))
		.pipe(inject(gulp.src('dist/js/lib/*.js').pipe(angularFilesort()), {
			ignorePath: '/dist/',
			addRootSlash: false
		}))
		.pipe(gulp.dest('dist'));
});

// Add production-only CDN-hosted third-party JS to index.html and copy to dist
// Also inject any third party JS from dist/js/lib
gulp.task('copy-index', ['copy-js'], function() {
	gulp.src('app/index.html')
		.pipe(replace(/<!-- production_only ([\s\S]*?)-->/g, '$1'))
		.pipe(inject(gulp.src('dist/js/lib/*.js').pipe(angularFilesort()), {
			ignorePath: '/dist/',
			addRootSlash: false
		}))
		.pipe(gulp.dest('dist'));
});

// Copy all non-index .html files to dist
gulp.task('copy-html', function() {
	gulp.src('app/*/**/*.html')
		.pipe(gulp.dest('dist'));
});

// Copy any images to dist/img
gulp.task('copy-images', function() {
	gulp.src('app/assets/img/*')
		.pipe(gulp.dest('dist/img'));
});

// Copy production-ready third-party JS from bower_components into dist/js/lib,
// and concatenate app JS and place in dist/js
//
// Only for use in production
gulp.task('copy-js', function() {
	var thirdPartySources = gulp.src([
		'bower_components/angular-local-storage/dist/angular-local-storage.min.js'
	]);

	return thirdPartySources.pipe(gulp.dest('dist/js/lib'));
});

// Copy third-party JS from bower_components into dist/js/lib, and concatenate
// app JS and place in dist/js
//
// Not for use in production
gulp.task('copy-js-dev', function() {
	var thirdPartySources = gulp.src([
		'bower_components/angular/angular.js',
		'bower_components/angular-route/angular-route.js',
		'bower_components/angular-local-storage/dist/angular-local-storage.js'
	]);

	thirdPartySources.pipe(gulp.dest('dist/js/lib'));

	return gulp.src('app/**/*.js')
		.pipe(concat('eventplanner.js'))
		.pipe(gulp.dest('dist/js'))
		.pipe(browserSync.stream());;
});

gulp.task('fonts', function() {
	gulp.src('bower_components/bootstrap-sass/assets/fonts/bootstrap/*.*')
		.pipe(gulp.dest('dist/fonts/bootstrap'));
});

// Prepare .scss styles for production (minify, autoprefix) and place in dist
gulp.task('styles', function() {
	gulp.src('app/assets/sass/**/*.scss')
		.pipe(sass({
			outputStyle: 'compressed'
		}).on('error', sass.logError))
		.pipe(autoprefixer({
			browsers: ['last 2 versions']
		}))
		.pipe(gulp.dest('dist/css'))
		.pipe(browserSync.stream());
});

// Run Jasmine integration tests in Chrome
gulp.task('tests', function() {
	gulp.src('app/**/*_test.js') // TODO multiple files?
		.pipe(jasmine({
			integration: true,
			vendor: 'app/**/*.js'
		}));
});
<commit_msg>style: Remove extra semicolon, TODO comment in gulpfile<commit_after>/*eslint-env node */

var gulp = require('gulp'),
	sass = require('gulp-sass'),
	autoprefixer = require('gulp-autoprefixer'),
	browserSync = require('browser-sync').create(),
	eslint = require('gulp-eslint'),
	jasmine = require('gulp-jasmine-phantom'),
	inject = require('gulp-inject'),
	replace = require('gulp-replace'),
	concat = require('gulp-concat'),
	uglify = require('gulp-uglify'),
	angularFilesort = require('gulp-angular-filesort');

gulp.task('default', ['copy-js-dev', 'copy-html', 'copy-index-dev', 'copy-images', 'styles', 'fonts', 'lint'], function() {
	gulp.watch('app/assets/sass/**/*.scss', ['styles']);
	gulp.watch(['app/app.js', 'app/**/*.js'], ['lint', 'copy-js-dev']);
	gulp.watch('app/*/**/*.html', ['copy-html']);
	gulp.watch('app/index.html', ['copy-index-dev']);
	gulp.watch('dist/**/*.html').on('change', browserSync.reload);

	browserSync.init({
		server: 'dist',
	});
});

// Build app to app/dist in production-ready state
gulp.task('dist', ['js-dist', 'copy-html', 'copy-index', 'copy-images', 'fonts', 'styles']);

// Concatenate and uglify app JS; place in dist/js
gulp.task('js-dist', ['copy-js'], function() {
	gulp.src('app/**/*.js')
		.pipe(concat('eventplanner.js'))
		.pipe(uglify())
		.pipe(gulp.dest('dist/js'));
});

// Run ESLint on any changes to app JS
gulp.task('lint', function() {
	return gulp.src('app/**/*.js')
		.pipe(eslint())
		.pipe(eslint.format())
		.pipe(eslint.failOnError());
});

// Inject locally-hosted third-party JS (e.g. Angular) into index.html
gulp.task('copy-index-dev', ['copy-js-dev'], function() {
	gulp.src('app/index.html')
		.pipe(replace(/<!-- dev_only ([\s\S]*?)-->/g, '$1'))
		.pipe(inject(gulp.src('dist/js/lib/*.js').pipe(angularFilesort()), {
			ignorePath: '/dist/',
			addRootSlash: false
		}))
		.pipe(gulp.dest('dist'));
});

// Add production-only CDN-hosted third-party JS to index.html and copy to dist
// Also inject any third party JS from dist/js/lib
gulp.task('copy-index', ['copy-js'], function() {
	gulp.src('app/index.html')
		.pipe(replace(/<!-- production_only ([\s\S]*?)-->/g, '$1'))
		.pipe(inject(gulp.src('dist/js/lib/*.js').pipe(angularFilesort()), {
			ignorePath: '/dist/',
			addRootSlash: false
		}))
		.pipe(gulp.dest('dist'));
});

// Copy all non-index .html files to dist
gulp.task('copy-html', function() {
	gulp.src('app/*/**/*.html')
		.pipe(gulp.dest('dist'));
});

// Copy any images to dist/img
gulp.task('copy-images', function() {
	gulp.src('app/assets/img/*')
		.pipe(gulp.dest('dist/img'));
});

// Copy production-ready third-party JS from bower_components into dist/js/lib,
// and concatenate app JS and place in dist/js
//
// Only for use in production
gulp.task('copy-js', function() {
	var thirdPartySources = gulp.src([
		'bower_components/angular-local-storage/dist/angular-local-storage.min.js'
	]);

	return thirdPartySources.pipe(gulp.dest('dist/js/lib'));
});

// Copy third-party JS from bower_components into dist/js/lib, and concatenate
// app JS and place in dist/js
//
// Not for use in production
gulp.task('copy-js-dev', function() {
	var thirdPartySources = gulp.src([
		'bower_components/angular/angular.js',
		'bower_components/angular-route/angular-route.js',
		'bower_components/angular-local-storage/dist/angular-local-storage.js'
	]);

	thirdPartySources.pipe(gulp.dest('dist/js/lib'));

	return gulp.src('app/**/*.js')
		.pipe(concat('eventplanner.js'))
		.pipe(gulp.dest('dist/js'))
		.pipe(browserSync.stream());
});

gulp.task('fonts', function() {
	gulp.src('bower_components/bootstrap-sass/assets/fonts/bootstrap/*.*')
		.pipe(gulp.dest('dist/fonts/bootstrap'));
});

// Prepare .scss styles for production (minify, autoprefix) and place in dist
gulp.task('styles', function() {
	gulp.src('app/assets/sass/**/*.scss')
		.pipe(sass({
			outputStyle: 'compressed'
		}).on('error', sass.logError))
		.pipe(autoprefixer({
			browsers: ['last 2 versions']
		}))
		.pipe(gulp.dest('dist/css'))
		.pipe(browserSync.stream());
});

// Run Jasmine integration tests in Chrome
gulp.task('tests', function() {
	gulp.src('app/**/*_test.js')
		.pipe(jasmine({
			integration: true,
			vendor: 'app/**/*.js'
		}));
});
<|endoftext|>