timestring/Gulpfile.js

89 lines
2.0 KiB
JavaScript
Raw Normal View History

2015-04-30 12:37:57 +02:00
var gulp = require('gulp');
var $ = require('gulp-load-plugins')({
scope: 'devDependencies'
});
2015-04-30 18:03:33 +02:00
2015-05-01 18:31:25 +02:00
var browserify = require('browserify');
2015-04-30 18:03:33 +02:00
var del = require('del');
2015-05-01 18:31:25 +02:00
var runSequence = require('run-sequence');
var source = require('vinyl-source-stream');
2015-04-30 12:37:57 +02:00
2015-04-30 18:03:33 +02:00
gulp.task('static-analysis:lint', function () {
2015-05-01 18:31:25 +02:00
gulp.src('src/timestring.js')
2015-04-30 12:37:57 +02:00
.pipe($.jshint('.jshintrc'))
.pipe($.jshint.reporter('jshint-stylish'));
});
2015-04-30 18:03:33 +02:00
gulp.task('static-analysis:cs', function () {
2015-05-01 18:31:25 +02:00
return gulp.src('src/timestring.js')
2015-04-30 12:37:57 +02:00
.pipe($.jscs());
});
gulp.task('test', function () {
2015-05-01 18:31:25 +02:00
return gulp.src('test/timestring.js', { read: false })
2015-04-30 12:37:57 +02:00
.pipe($.mocha());
});
2015-04-30 18:03:33 +02:00
gulp.task('build:clean', function (callback) {
del(['build/**/*'], callback);
});
2015-05-01 18:31:25 +02:00
gulp.task('build:transpile', function () {
return gulp.src('src/timestring.js')
.pipe($.sourcemaps.init())
.pipe($.babel())
.pipe($.sourcemaps.write())
2015-04-30 18:03:33 +02:00
.pipe(gulp.dest('build'));
});
2015-05-01 18:31:25 +02:00
gulp.task('build:lib', function () {
return gulp.src('build/timestring.js')
.pipe(gulp.dest('dist/lib'));
});
gulp.task('build:browserify', function() {
return browserify('./build/timestring.js', { standalone: 'Timestring', debug: true })
.bundle()
.on('error', function(e){
console.log(e.message);
this.emit('end');
})
.pipe(source('timestring.js'))
2015-04-30 18:03:33 +02:00
.pipe(gulp.dest('dist'));
});
gulp.task('build:minify', function () {
2015-05-01 18:31:25 +02:00
return gulp.src('build/timestring.js')
2015-04-30 12:37:57 +02:00
.pipe($.uglify())
.pipe($.rename({
extname: '.min.js'
}))
.pipe(gulp.dest('dist'));
});
gulp.task('build', function (callback) {
runSequence(
2015-05-01 18:31:25 +02:00
['static-analysis:lint', 'static-analysis:cs'],
2015-04-30 18:03:33 +02:00
'build:clean',
2015-05-01 18:31:25 +02:00
'build:transpile',
'test',
['build:lib', 'build:browserify'],
2015-04-30 18:03:33 +02:00
'build:minify',
2015-04-30 12:37:57 +02:00
callback
);
});
2015-04-30 18:03:33 +02:00
gulp.task('sa', ['static-analysis:lint', 'static-analysis:cs']);
2015-05-01 18:31:25 +02:00
gulp.task('ci', function (callback) {
runSequence(
['static-analysis:lint', 'static-analysis:cs'],
'build:clean',
'build:transpile',
'test'
);
});
2015-04-30 12:37:57 +02:00
gulp.task('default', ['build']);