This repository has been archived by the owner on Jan 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.coffee
99 lines (89 loc) · 2.57 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
95
96
97
98
99
gulp = require 'gulp'
gutil = require 'gulp-util'
paths =
src: './src/**/*.coffee'
test: './test/**/*.coffee'
coverage: './coverage/**/lcov.info'
coverageDir: './coverage/'
compiledDir: './.tmp/'
compiledSrc: './.tmp/src/**/*.js'
compiledSrcDir: './.tmp/src/'
compiledTest: './.tmp/test/**/*.js'
compiledTestDir: './.tmp/test/'
buildDir: './lib/'
hubotHelp =
init: ->
through = require 'through2'
through.obj (file, encoding, next) ->
help = for line in file.contents.toString().split('\n')
break unless line[0] is '#' or line.substring(0, 2) is '//'
line.replace(new RegExp('^#(\\s*)'), '//$1')
file.hubotHelp = help.join('\n') + '\n'
next null, file
write: ->
through = require 'through2'
through.obj (file, encoding, next) ->
return next(null, file) unless file.hubotHelp?
file.contents = Buffer.concat [
new Buffer(file.hubotHelp)
file.contents
]
next null, file
gulp.task 'clean', (done) ->
del = require 'del'
del [
paths.compiledDir
paths.coverageDir
paths.buildDir
], done
gulp.task 'coveralls', ->
coveralls = require 'gulp-coveralls'
gulp
.src paths.coverage
.pipe coveralls()
gulp.task 'build', ->
coffee = require 'gulp-coffee'
gulp
.src paths.src
.pipe hubotHelp.init()
.pipe coffee(bare: true).on('error', gutil.log)
.pipe hubotHelp.write()
.pipe gulp.dest(paths.buildDir)
gulp.task 'compile-src', ->
coffee = require 'gulp-coffee'
sourcemaps = require 'gulp-sourcemaps'
gulp
.src paths.src
.pipe sourcemaps.init()
.pipe hubotHelp.init()
.pipe coffee(bare: true).on('error', gutil.log)
.pipe hubotHelp.write()
.pipe sourcemaps.write()
.pipe gulp.dest(paths.compiledSrcDir)
gulp.task 'compile-test', ->
coffee = require 'gulp-coffee'
espower = require 'gulp-espower'
sourcemaps = require 'gulp-sourcemaps'
gulp
.src paths.test
.pipe sourcemaps.init()
.pipe coffee(bare: true).on('error', gutil.log)
.pipe espower()
.pipe sourcemaps.write()
.pipe gulp.dest(paths.compiledTestDir)
gulp.task 'test', ['compile-src', 'compile-test'], ->
istanbul = require 'gulp-istanbul'
mocha = require 'gulp-mocha'
gulp
.src paths.compiledSrc
.pipe istanbul()
.on 'finish', ->
gulp
.src paths.compiledTest
.pipe mocha().on('error', gutil.log)
.pipe istanbul.writeReports(paths.coverageDir)
# FIXME
.on 'end', -> process.exit(0)
gulp.task 'watch', ->
gulp.watch [paths.src, paths.test], ['test']
gulp.task 'default', ['build']