Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var gulp = require('gulp'),
- concat = require('gulp-concat-util'),
- header = require('gulp-header'),
- footer = require('gulp-footer'),
- del = require('del'),
- merge = require('merge-stream'),
- jshint = require('gulp-jshint'),
- jasmine = require('gulp-jasmine'),
- source = require('vinyl-source-stream'),
- buffer = require('gulp-buffer'),
- browserify = require('browserify'),
- rename = require("gulp-rename"),
- transform = require('vinyl-transform'),
- through = require('through2'),
- fs = require('fs');
- function getAppStream() {
- return browserify('src/js/app/main.js')
- .bundle()
- .pipe(source('app.js'))
- .pipe(buffer());
- }
- gulp.task('lint:app', function () {
- return gulp.src(['src/js/app/**/*.js'])
- .pipe(jshint())
- .pipe(jshint.reporter('default'));
- });
- gulp.task('clean', function () {
- return del(['build']);
- });
- gulp.task('vendor', ['clean'], function () {
- return gulp.src(['vendor/**'])
- .pipe(gulp.dest('build/vendor'));
- });
- gulp.task('css', ['clean'], function () {
- return gulp.src(['src/css/**/*.css'])
- .pipe(concat('app.css'))
- .pipe(gulp.dest('build'));
- });
- gulp.task('js', ['clean', 'lint:app'], function () {
- var app = getAppStream()
- .pipe(header('(function(global) {'))
- .pipe(footer('}(window.TwitchLanguageFilter = window.TwitchLanguageFilter || {}));'));
- var manifest = gulp.src(['src/manifest.json']);
- var launcher = gulp.src(['src/js/launcher.js'])
- .pipe(jshint())
- .pipe(jshint.reporter('default'))
- return merge(app, launcher, manifest)
- .pipe(gulp.dest('build'));
- });
- gulp.task('test', function () {
- return gulp.src(['test/**/*.spec.js'])
- .pipe(jasmine());
- });
- gulp.task('dev', ['js', 'css', 'vendor'], function () {
- });
- if (!String.prototype.endsWith) {
- String.prototype.endsWith = function (searchString, position) {
- var subjectString = this.toString();
- if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
- position = subjectString.length;
- }
- position -= searchString.length;
- var lastIndex = subjectString.indexOf(searchString, position);
- return lastIndex !== -1 && lastIndex === position;
- };
- }
- gulp.task('env', ['clean'], function () {
- var configTransform = function (file) {
- return through(function (buff, enc, next) {
- if (file.endsWith('config\\index.js')) {
- var config = fs.readFileSync('src/js/app/config/debug.config.js', 'utf8');
- this.push(config);
- } else {
- this.push(buff);
- }
- next();
- });
- };
- browserify('src/js/app/main.js')
- .transform(configTransform)
- .bundle()
- .pipe(source('app.js'))
- .pipe(buffer())
- .pipe(gulp.dest('build'));
- });
- gulp.task('watch', ['default'], function () {
- gulp.watch(['src/**', 'test/**'], ['default']);
- });
- gulp.task('default', ['dev', 'test'], function () {
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement