-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
126 lines (107 loc) · 3.51 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
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
st = require 'st'
http = require 'http'
gulp = require 'gulp'
through = require 'through2'
$ = require('gulp-load-plugins')()
{shell} = require 'execa'
gulp.task 'build:coffee', ->
gulp.src 'src/**/*.coffee'
.pipe $.plumber
errorHandler:
$.notify.onError
title: 'Cannot compile CoffeeScript'
message: '<%= error.message %>'
.pipe $.coffee()
.pipe gulp.dest 'dist'
.pipe $.livereload()
gulp.task 'lint:coffee', ->
formatter = (file) ->
file.coffeelint.results
.getErrors(file.relative)
.map (err) -> "#{file.relative}|\##{err.lineNumber}: #{err.context or err.message}"
.join '\n'
gulp.src 'src/**/*.coffee'
.pipe $.plumber
errorHandler:
$.notify.onError
title: '<%= error.message.split("|")[0] %>'
message: '<%= error.message.split("|")[1] %>'
.pipe $.coffeelint()
.pipe $.coffeelint.reporter('coffeelint-stylish')
.pipe through.obj (file, enc, cb) ->
unless file.coffeelint.success
@emit 'error', new $.util.PluginError 'gulp-coffeelint', formatter(file)
cb()
gulp.task 'lint:js', ->
gulp.src 'src/**/*.js'
.pipe $.plumber
errorHandler:
$.notify.onError
title: 'Invalid JavaScript'
message: '<%= error.message %>'
.pipe $.xo()
gulp.task 'build:pug', ->
gulp.src 'src/**/*.jade'
.pipe $.pug()
.pipe gulp.dest 'dist'
.pipe $.livereload()
gulp.task 'copy:js', ->
gulp.src 'src/**/*.js'
.pipe gulp.dest 'dist'
.pipe $.livereload()
gulp.task 'copy:css', ->
gulp.src 'src/**/*.css'
.pipe gulp.dest 'dist'
.pipe $.livereload()
gulp.task 'copy:libs', ->
gulp.src([
'libs/jquery-ui/themes/base/jquery-ui.css'
'libs/jqGrid/css/ui.jqgrid.css'
'libs/jqGrid/css/ui.jqgrid-bootstrap.css'
'libs/jqGrid/css/ui.jqgrid-bootstrap-ui.css'
'libs/jquery/dist/jquery.js'
'libs/jqGrid/js/jquery.jqGrid.js'
'libs/highcharts/highcharts.js'
])
.pipe gulp.dest 'dist/libs'
gulp.task 'copy:images', ->
gulp.src 'libs/jquery-ui/themes/base/images/**/*.*'
.pipe gulp.dest 'dist/libs/images'
gulp.task 'copy:fonts', ->
gulp.src 'libs/bootstrap/dist/fonts/**/*.*'
.pipe gulp.dest 'dist/fonts'
gulp.task 'copy', [
'copy:js'
'copy:css'
'copy:libs'
'copy:images'
'copy:fonts'
]
gulp.task 'lint', [
'lint:coffee'
'lint:js'
]
gulp.task 'build', [
'build:coffee'
'build:pug'
'lint'
'copy'
]
gulp.task 'server', ['build'], (done) ->
port = process.env.PORT or 8081
console.log "Server ready for requests: http://localhost:#{port}/"
http.createServer st
path : __dirname + '/dist'
index : 'index.html'
cache : false
.listen port, done
gulp.task 'watch', ['server'], ->
$.livereload.listen basePath: 'dist'
gulp.watch 'src/**/*.jade', ['build:pug']
gulp.watch 'src/**/*.coffee', ['build:coffee', 'lint:coffee']
gulp.watch 'src/**/*.js', ['copy:js', 'lint:js']
gulp.watch 'src/**/*.css', ['copy:css']
gulp.task 'hotel:init', ->
shell 'hotel add "gulp server"'
gulp.task 'hotel:remove', ->
shell 'hotel rm'