-
Notifications
You must be signed in to change notification settings - Fork 31
/
gulpfile.js
56 lines (44 loc) · 1.75 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
(function main($gulp) {
var babel = require('gulp-babel'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
karma = require('gulp-karma'),
path = require('path'),
yaml = require('js-yaml'),
fs = require('fs'),
config = yaml.safeLoad(fs.readFileSync('./droplet.yml', 'utf8'));
$gulp.task('compile', function() {
return $gulp.src(config.module)
.pipe(babel())
.pipe(rename(config.name + '.js'))
.pipe($gulp.dest(config.locations.release))
.pipe($gulp.dest(config.locations.vendor + '/' + config.name))
.pipe(uglify())
.pipe(rename(function (path) {
path.basename += '.min';
}))
.pipe($gulp.dest(config.locations.release));
});
$gulp.task('lint', function() {
return $gulp.src(config.module)
.pipe(jshint())
.pipe(jshint.reporter(require('jshint-stylish')));
});
$gulp.task('karma', function() {
return $gulp.src([].concat(config.dependencies, config.tests, config.module))
.pipe(karma({
configFile: 'karma.conf.js',
action: 'run'
}))
.on('error', function(err) {
throw err;
});
});
$gulp.task('test', ['lint', 'karma']);
$gulp.task('build', ['compile']);
$gulp.task('default', ['test', 'build']);
$gulp.task('watch', function watch() {
$gulp.watch(config.module, ['build']);
});
})(require('gulp'));