2015-08-02 06:25:08 +00:00
|
|
|
'use strict'; /* eslint strict:0, no-var:0, func-names:0 */
|
2015-08-04 17:39:56 +00:00
|
|
|
var path = require('path');
|
2015-07-31 15:53:25 +00:00
|
|
|
var gulp = require('gulp');
|
2015-08-04 17:08:44 +00:00
|
|
|
|
|
|
|
var babel = require('gulp-babel');
|
2015-07-31 15:53:25 +00:00
|
|
|
var eslint = require('gulp-eslint');
|
|
|
|
var mocha = require('gulp-mocha');
|
|
|
|
var nsp = require('gulp-nsp');
|
2015-08-02 07:48:08 +00:00
|
|
|
var rimraf = require('rimraf');
|
2015-08-04 17:08:44 +00:00
|
|
|
var webpack = require('webpack-stream');
|
|
|
|
|
2015-08-04 17:39:56 +00:00
|
|
|
var KarmaServer = require('karma').Server;
|
|
|
|
|
2015-08-04 17:08:44 +00:00
|
|
|
var createWebpackConfig = require('./createWebpackConfig.js');
|
2015-07-31 15:53:25 +00:00
|
|
|
|
|
|
|
// Initialize the babel transpiler so ES2015 files gets compiled
|
|
|
|
// when they're loaded
|
|
|
|
require('babel-core/register');
|
|
|
|
|
2015-08-02 07:48:08 +00:00
|
|
|
gulp.task('clean', function(cb) {
|
|
|
|
rimraf('./dist', cb);
|
|
|
|
});
|
|
|
|
|
2015-08-02 06:25:08 +00:00
|
|
|
gulp.task('static', function() {
|
2015-08-19 07:31:06 +00:00
|
|
|
return gulp.src(['*.js', 'lib/**/*.js', 'test/**/*.js'])
|
2015-07-31 15:53:25 +00:00
|
|
|
.pipe(eslint())
|
|
|
|
.pipe(eslint.format())
|
2015-08-01 15:13:25 +00:00
|
|
|
.pipe(eslint.failAfterError());
|
2015-07-31 15:53:25 +00:00
|
|
|
});
|
|
|
|
|
2015-08-02 06:25:08 +00:00
|
|
|
gulp.task('nsp', function(cb) {
|
2015-07-31 15:53:25 +00:00
|
|
|
nsp('package.json', cb);
|
|
|
|
});
|
|
|
|
|
2015-08-04 17:39:56 +00:00
|
|
|
gulp.task('test', ['test:karma', 'test:node']);
|
|
|
|
|
|
|
|
gulp.task('test:node', function() {
|
2015-08-01 15:43:21 +00:00
|
|
|
return gulp.src('test/**/*.js')
|
2015-08-05 15:26:44 +00:00
|
|
|
.pipe(mocha({reporter: 'dot'}));
|
2015-07-31 15:53:25 +00:00
|
|
|
});
|
|
|
|
|
2015-08-04 17:39:56 +00:00
|
|
|
gulp.task('test:karma', function(done) {
|
|
|
|
new KarmaServer({
|
|
|
|
configFile: path.join(__dirname, 'karma.conf.js'),
|
|
|
|
singleRun: true,
|
|
|
|
}, done).start();
|
|
|
|
});
|
|
|
|
|
2015-08-04 17:08:44 +00:00
|
|
|
gulp.task('babel', function() {
|
2015-07-31 15:53:25 +00:00
|
|
|
return gulp.src('lib/**/*.js')
|
|
|
|
.pipe(babel())
|
|
|
|
.pipe(gulp.dest('dist'));
|
|
|
|
});
|
|
|
|
|
2015-08-06 05:48:07 +00:00
|
|
|
gulp.task('watch', function() {
|
|
|
|
gulp.start(['test:node']);
|
|
|
|
gulp.watch(['lib/**/*.js', 'test/**/*.js'], ['test:node']);
|
2015-08-05 15:26:44 +00:00
|
|
|
new KarmaServer({
|
|
|
|
configFile: path.join(__dirname, 'karma.conf.js'),
|
2015-08-06 05:48:07 +00:00
|
|
|
}).start();
|
2015-08-02 05:51:56 +00:00
|
|
|
});
|
|
|
|
|
2015-08-04 17:08:44 +00:00
|
|
|
gulp.task('webpack', ['webpack:standalone', 'webpack:standalone:min']);
|
|
|
|
|
|
|
|
gulp.task('webpack:standalone', function() {
|
|
|
|
var config = createWebpackConfig({ filename: 'updeep-standalone.js' });
|
|
|
|
|
|
|
|
return gulp.src('lib/index.js')
|
|
|
|
.pipe(webpack(config))
|
|
|
|
.pipe(gulp.dest('dist/umd/'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('webpack:standalone:min', function() {
|
|
|
|
var config = createWebpackConfig({
|
|
|
|
filename: 'updeep-standalone.min.js',
|
|
|
|
minify: true,
|
2015-08-10 05:40:23 +00:00
|
|
|
env: 'production',
|
2015-08-04 17:08:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return gulp.src('lib/index.js')
|
|
|
|
.pipe(webpack(config))
|
|
|
|
.pipe(gulp.dest('dist/umd/'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('build', ['babel', 'webpack']);
|
|
|
|
|
|
|
|
gulp.task('build:clean', ['clean'], function(done) {
|
|
|
|
gulp.start('build', done);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('prepublish', ['nsp', 'build:clean']);
|
2015-08-01 15:43:21 +00:00
|
|
|
gulp.task('default', ['static', 'test']);
|