| 1 |
var gulp = require('gulp'), |
| 2 |
coffee = require('gulp-coffee'), |
| 3 |
concat = require('gulp-concat'), |
| 4 |
fancylog = require('fancy-log'); |
| 5 |
|
| 6 |
var name = 'jquery.atwho'; |
| 7 |
|
| 8 |
gulp.task('coffee', function (done) { |
| 9 |
gulp.src('src/*.coffee') |
| 10 |
.pipe(coffee({bare: true}).on('error', fancylog)) |
| 11 |
.pipe(gulp.dest('./build/js')); |
| 12 |
done(); |
| 13 |
}); |
| 14 |
|
| 15 |
gulp.task('concat', function (done) { |
| 16 |
fileList = [ |
| 17 |
'build/js/default.js', |
| 18 |
'build/js/app.js', |
| 19 |
'build/js/controller.js', |
| 20 |
'build/js/textareaController.js', |
| 21 |
'build/js/editableController.js', |
| 22 |
'build/js/model.js', |
| 23 |
'build/js/view.js', |
| 24 |
'build/js/api.js' |
| 25 |
] |
| 26 |
gulp.src(fileList) |
| 27 |
.pipe(concat(name + ".js")) |
| 28 |
.pipe(gulp.dest('build')); |
| 29 |
done(); |
| 30 |
}); |
| 31 |
|
| 32 |
gulp.task('umd', function (done) { |
| 33 |
gulp.src('build/' + name + ".js") |
| 34 |
.pipe(umd({template: "umd.template.js"})) |
| 35 |
.pipe(gulp.dest('build/js')); |
| 36 |
done(); |
| 37 |
}); |
| 38 |
|
| 39 |
gulp.task('bump', function (done) { |
| 40 |
gulp.src(['bower.json', 'component.json', 'package.json']) |
| 41 |
.pipe(bump({version: "1.5.4"})) |
| 42 |
.pipe(gulp.dest('./')); |
| 43 |
done(); |
| 44 |
}); |
| 45 |
|
| 46 |
gulp.task("mark", function (done) { |
| 47 |
var pkg = require('./package.json'); |
| 48 |
var banner = ['/**', |
| 49 |
' * <%= pkg.name %> - <%= pkg.version %>', |
| 50 |
' * Copyright (c) <%= year %> <%= pkg.author.name %> <<%= pkg.author.email %>>;', |
| 51 |
' * Homepage: <%= pkg.homepage %>', |
| 52 |
' * License: <%= pkg.license %>', |
| 53 |
' */', |
| 54 |
''].join('\n'); |
| 55 |
|
| 56 |
gulp.src('build/js/' + name + '.js') |
| 57 |
.pipe(header(banner, { pkg : pkg, year: (new Date).getFullYear()})) |
| 58 |
.pipe(gulp.dest('dist/js/')) |
| 59 |
done(); |
| 60 |
}); |
| 61 |
|
| 62 |
gulp.task('compress', function (done) { |
| 63 |
gulp.src('dist/js/' + name + '.js') |
| 64 |
.pipe(uglify()) |
| 65 |
.pipe(rename({suffix: '.min'})) |
| 66 |
.pipe(gulp.dest('dist/js')); |
| 67 |
|
| 68 |
gulp.src('src/jquery.atwho.css').pipe(gulp.dest('dist/css')) |
| 69 |
gulp.src('dist/css/' + name + '.css') |
| 70 |
.pipe(cssmin()) |
| 71 |
.pipe(rename({suffix: '.min'})) |
| 72 |
.pipe(gulp.dest('dist/css')); |
| 73 |
done(); |
| 74 |
}); |
| 75 |
|
| 76 |
gulp.task('test', function (done) { |
| 77 |
gulp.src('spec/**/*.coffee') |
| 78 |
.pipe(coffee({bare: true}).on('error', fancylog)) |
| 79 |
.pipe(debug({title: "compiled specs"})) |
| 80 |
.pipe(gulp.dest('spec/build')) |
| 81 |
|
| 82 |
gulp.src('spec/build/javascripts/*.spec.js') |
| 83 |
.pipe(jasmine({ |
| 84 |
integration: true, |
| 85 |
specHtml: "specRunner.html" |
| 86 |
/* TODO: have to add css to spec |
| 87 |
vendor: [ |
| 88 |
'bower_components/jquery/dist/jquery.js', |
| 89 |
'bower_components/Caret.js/dist/jquery.caret.js', |
| 90 |
'dist/js/jquery.atwho.js', |
| 91 |
'node_modules/jasmine-jquery/lib/*.js', |
| 92 |
'node_modules/jasmine-ajax/lib/*.js', |
| 93 |
'spec/helpers/*.js', |
| 94 |
'spec/build/spec_helper.js' |
| 95 |
], |
| 96 |
*/ |
| 97 |
})); |
| 98 |
done(); |
| 99 |
}); |
| 100 |
|