forked from dalelotts/angular-bootstrap-datetimepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
144 lines (114 loc) · 3.34 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*globals require, __dirname */
/* jshint node:true */
'use strict';
var csslint = require('gulp-csslint');
var gulp = require('gulp');
var jscs = require('gulp-jscs');
var jshint = require('gulp-jshint');
var karmaConfig = __dirname + '/karma.conf.js';
var lodash = require('lodash');
var paths = require('./paths');
var plato = require('plato');
var Server = require('karma').Server;
var path = require('path');
gulp.task('build-css', ['scss'], function () {
var Comb = require('csscomb');
var config = require('./.csscomb.json');
var comb = new Comb(config);
comb.processPath('./src/css/');
});
gulp.task('clean', function () {
var del = require('del');
return del([
'build'
]);
});
gulp.task('default', ['clean:mobile']);
gulp.task('complexity', function (done) {
var callback = function () {
done();
};
plato.inspect(paths.lint, 'build/complexity', {title: 'prerender', recurse: true}, callback);
});
gulp.task('csslint', function () {
return gulp.src(paths.css)
.pipe(csslint())
.pipe(csslint.reporter())
.pipe(csslint.failReporter());
});
gulp.task('jscs', function () {
return gulp
.src(paths.lint)
.pipe(jscs('.jscsrc'));
});
gulp.task('lint', function () {
return gulp
.src(paths.lint)
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default', {verbose: true}))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('scss', ['scss-lint'], function () {
var scss = require('gulp-sass');
var postcss = require('gulp-postcss');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('autoprefixer');
return gulp.src(paths.scss)
.pipe(scss())
.pipe(sourcemaps.init())
.pipe(postcss([autoprefixer({browsers: ['last 2 versions']})]))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./src/css'));
});
gulp.task('scss-lint', function () {
var scssLint = require('gulp-scss-lint');
var scssLintStylish = require('gulp-scss-lint-stylish');
return gulp.src('./src/scss/*.scss')
.pipe(scssLint({customReport: scssLintStylish}));
});
var testConfig = function (options) {
var travisOptions = process.env.TRAVIS &&
{
browsers: ['Firefox'],
reporters: ['dots', 'coverage', 'threshold']
};
return lodash.assign(options, travisOptions);
};
gulp.task('templatecache', function () {
var templateCache = require('gulp-angular-templatecache');
var htmlMin = require('gulp-htmlmin');
return gulp
.src('src/templates/**/*.html')
.pipe(htmlMin({removeComments: true}))
.pipe(templateCache('datetimepicker.templates.js', {
base: path.join(__dirname, 'src'),
module: 'ui.bootstrap.datetimepicker'
}))
.pipe(gulp.dest('src/js'));
});
gulp.task('tdd', function (done) {
gulp.watch(paths.all.concat(paths.scss), ['jscs', 'lint', 'build-css']);
var config = testConfig(
{
autoWatch: true,
browsers: ['PhantomJS'],
configFile: karmaConfig,
singleRun: false
}
);
var server = new Server(config, done);
server.start();
});
gulp.task('test', ['jscs', 'lint', 'csslint'], function (done) {
var config = testConfig(
{
configFile: karmaConfig,
singleRun: true,
reporters: ['progress', 'coverage', 'threshold']
}
);
var server = new Server(config, done);
server.start();
});
gulp.task('default', ['complexity', 'test']);