-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.coffee
94 lines (76 loc) · 2.25 KB
/
gulpfile.coffee
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
gulp = require('gulp')
plumber = require('gulp-plumber')
gutil = require('gulp-util')
coffee = require('gulp-coffee')
# Code linting
coffeelint = require('gulp-coffeelint')
# Code minification
concat = require('gulp-concat')
uglify = require('gulp-uglify')
# Angular
protractor = require('gulp-protractor').protractor
ngTemplates = require('gulp-ng-templates')
ngAnnotate = require('gulp-ng-annotate')
# Notifications for OSX
notify = require('gulp-notify')
errorHandler = notify.onError('Error: <%= error.message %>')
gulp.task 'test', ->
gulp
.src(['test/specs/**/*.js'])
.pipe(protractor(
configFile: 'test/conf.js'
))
.pipe(plumber({errorHandler}))
.on('error', gutil.log)
.on('error', gutil.beep)
gulp.task 'partials', (done) ->
gulp
.src('src/partials/**/*.html')
.pipe(ngTemplates('batteryTemplates'))
.pipe(gulp.dest('tmp/templates'))
gulp.task 'concat-dist', (done) ->
gulp
.src('tmp/**/*.js')
.pipe(plumber({errorHandler}))
.on('error', gutil.log)
.on('error', gutil.beep)
.pipe(concat('battery-level.js'))
.pipe(gulp.dest('./dist'))
gulp.task 'build-min', ['concat-dist'], (done) ->
gulp
.src('tmp/**/*.js')
.pipe(plumber({errorHandler}))
.on('error', gutil.log)
.on('error', gutil.beep)
.pipe(concat('battery-level.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./dist'))
gulp.task 'build', ['coffee', 'partials'], ->
gulp.start('build-min')
gutil.log 'Build complete'
gulp.task 'ci', ['build-min', 'build'], ->
gulp.start('test')
gulp.task 'coffeelint', ->
gulp
.src('src/**/*.coffee')
.pipe(plumber({errorHandler}))
.pipe(coffeelint())
.pipe(coffeelint.reporter())
.pipe(coffeelint.reporter('fail'))
.on('error', gutil.log)
.on('error', gutil.beep)
gulp.task 'coffee', ->
gulp
.src('src/**/*.coffee')
.pipe(plumber({errorHandler}))
.pipe(coffee())
.on('error', gutil.log)
.on('error', gutil.beep)
.pipe(ngAnnotate())
.pipe(concat('battery-level.js'))
.pipe(gulp.dest('tmp'))
gulp.task 'watch', ->
gulp.watch ['src/**/*.coffee'], ['coffeelint', 'coffee']
gulp.watch ['src/partials/**/*.html'], ['partials']
gulp.task 'default', ->
gutil.log 'Available commands: watch, coffee, coffeelint, partials, build'