-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgulpfile.coffee
79 lines (65 loc) · 2.22 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
gulp = require 'gulp'
coffee = require 'gulp-coffee'
coffeelint = require 'gulp-coffeelint'
uglify = require 'gulp-uglify'
filter = require 'gulp-filter'
sourcemaps = require 'gulp-sourcemaps'
mocha = require 'gulp-mocha'
istanbul = require 'gulp-istanbul'
rename = require 'gulp-rename'
docco = require 'gulp-docco'
del = require 'del'
paths =
src: ['src/**/*.coffee']
demo: ['demo/**/*', 'build/js/quadtree.min.js', 'build/js/quadtree.min.js.map']
test: ['test/*.coffee']
perf: ['test/perf/*.coffee']
docindex: ['docs/quadtree.html']
gulp.task 'clean', ->
del ['build', 'docs', 'coverage']
gulp.task 'lint', ->
gulp.src [paths.src..., paths.test..., paths.perf..., 'gulpfile.coffee']
.pipe(coffeelint())
.pipe(coffeelint.reporter())
.pipe(coffeelint.reporter('fail'))
gulp.task 'build', ['lint'], ->
gulp.src paths.src
.pipe sourcemaps.init()
.pipe coffee bare: true
.pipe sourcemaps.write '.'
.pipe gulp.dest('build/js')
.pipe filter('**/*.js')
.pipe uglify()
.pipe rename extname: '.min.js'
.pipe sourcemaps.write '.'
.pipe gulp.dest 'build/js'
gulp.task 'pre-test', ['build'], ->
gulp.src 'build/js/quadtree.js'
.pipe istanbul()
.pipe istanbul.hookRequire()
gulp.task 'test', ['pre-test'], ->
gulp.src paths.test, read: false
.pipe mocha reporter: 'nyan'
.pipe istanbul.writeReports()
gulp.task 'perf', ['build'], ->
gulp.src paths.perf, read: false
.pipe mocha reporter: 'spec'
gulp.task 'watch', ->
gulp.watch [paths.src, paths.test], ['build', 'test']
gulp.task 'generatedoc', ->
gulp.src paths.src
.pipe docco layout: 'linear'
.pipe gulp.dest './docs'
gulp.task 'setupdemo', ->
gulp.src paths.demo
.pipe gulp.dest './docs/demo'
gulp.task 'copyassets', ->
gulp.src 'assets/**/*'
.pipe gulp.dest './docs/assets'
gulp.task 'doc', ['generatedoc', 'setupdemo', 'copyassets'], ->
gulp.src paths.docindex
.pipe rename 'index.html'
.pipe gulp.dest './docs'
gulp.task 'watchdemo', ->
gulp.watch ['./demo/**'], ['setupdemo']
gulp.task 'default', ['test']