forked from Diokuz/baron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
121 lines (105 loc) · 2.69 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
var _ = require('lodash');
var gulp = require('gulp');
var argv = require('yargs').argv;
var runSequence = require('run-sequence');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');
var concat = require('gulp-concat');
var removeCode = require('gulp-remove-code');
var uglify = require('gulp-uglify');
var mochaPhantomJS = require('gulp-mocha-phantomjs');
function buildFiles(params) {
var full = ['core', 'fix', 'autoUpdate', 'controls', 'pull', 'test', 'debug'];
var fns;
params = params || {};
if (params.full) {
fns = full;
} else if (params.core) {
fns = ['core', 'autoUpdate'];
} else {
fns = _.difference(full, ['test', 'pull']);
}
return _.map(fns, function(fn) {
return 'src/' + fn + '.js';
});
}
/**
* Linters
*/
gulp.task('lint.jshint', function() {
return gulp.src([
'src/**/*.js',
'demo/**/*.js',
'test/**/*.js'
])
.pipe(jshint('config/.jshint'))
.pipe(jshint.reporter('jshint-summary', {
verbose: true,
reasonCol: 'cyan,bold'
}))
.on('jshint.failed', function() {
console.log('[lint.jshint] failed');
});
});
gulp.task('lint.jscs', function() {
return gulp.src([
'src/**/*.js',
'test/**/*.js'
])
.pipe(jscs('config/.jscs'))
.on('jscs.failed', function() {
console.log('[lint.jscs] failed');
});
});
gulp.task('lint', ['lint.jshint', 'lint.jscs']);
/**
* Build
*/
gulp.task('build.demo', function() {
return gulp.src(buildFiles())
.pipe(concat('baron.js'))
.pipe(gulp.dest('demo/'));
});
gulp.task('build.baron', function() {
return gulp.src(buildFiles(argv))
.pipe(concat('baron.js'))
.pipe(gulp.dest('dist/'))
.pipe(removeCode({production: true}))
.pipe(uglify({
compress: {
global_defs: {
DEBUG: false
},
unsafe: true
}
}))
.pipe(concat('baron.min.js'))
.pipe(gulp.dest('dist/'));
});
// Копируем в корень собранные файлы, чтоб в репе были готовые версии
gulp.task('copy', ['build.baron'], function() {
return gulp.src([
'dist/baron.js',
'dist/baron.min.js'
])
.pipe(gulp.dest('./'))
});
gulp.task('build', ['build.baron', 'build.demo', 'copy']);
gulp.task('default', ['build']);
/**
* Tests
*/
gulp.task('test', function() {
return gulp.src(['test/*.auto.html'])
.pipe(mochaPhantomJS({
phantomjs: {
viewportSize: {
width: 1024,
height: 768
}
}
}));
});
gulp.task('t', function(cb) {
runSequence('lint', 'build', 'test');
});