-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulp.coffee
92 lines (74 loc) · 2.36 KB
/
gulp.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
c = console
gulp = require 'gulp'
jade = require 'gulp-jade'
coffee = require 'gulp-coffee'
stylus = require 'gulp-stylus'
nib = require 'nib'
sourcemaps = require 'gulp-sourcemaps'
express = require 'express'
livereload = require 'gulp-livereload'
connectLr = require 'connect-livereload'
exec = require('child_process').exec
###
Build Settings should mostly work as they are
###
serverPort = 8080
buildDir = "dist"
srcDir = "src"
###
We'd like to setup an environment where all our src files are watched
and transpiled immedately on file save. Not only that but the browser
is hot loaded with the latest code as we are making changes.
TODO: Run jasmine tests everytime any js files are modified.
###
handle = (stream) ->
stream.on 'error', (err) ->
c.log err
stream.end()
return stream
gulp.task 'jade', ->
gulp.src 'src/**/*.jade'
.pipe handle(jade(pretty: true))
.pipe gulp.dest buildDir
gulp.task 'styl', ->
gulp.src 'src/**/*.styl'
.pipe handle(stylus(use: nib()))
.pipe gulp.dest buildDir
gulp.task 'coffee', ->
gulp.src 'src/**/*.coffee'
.pipe handle(coffee(bare: true))
.pipe gulp.dest buildDir
gulp.task 'assets', ->
gulp.src 'src/assets/**'
.pipe gulp.dest buildDir + "/assets"
###
'You press a button and we do the rest'
###
gulp.task 'server', ->
app = express()
app.use connectLr()
app.use express.static __dirname + '/' + buildDir
app.listen serverPort
gulp.task 'watch', ['server'], ->
gulp.watch 'src/**/*.jade', ['jade']
gulp.watch 'src/**/*.coffee', ['coffee']
gulp.watch 'src/**/*.styl', ['styl']
gulp.watch 'src/assets/**', ['assets']
gulp.watch(buildDir + '/*').on('change', (e) -> livereload.changed(e.path))
livereload.listen()
gulp.task 'gh-pages', ->
logger = (err, stdout, stderr) ->
c.log stdout if stdout
c.log stderr if stderr
exec "git subtree push --prefix dist dist gh-pages", logger
###
Running "gulp" in command line will automatically setup src watching + live reload
Running "gulp build" will build into the dist folder.
Running "gulp deploy" will build and commit into the gh-pages branch.
The site will be accessible at https://username.github.io/uber-sudoku
Thanks to: http://spin.atomicobject.com/2014/03/28/deploy-git-subtrees/
TODO: Add test runner in build code.
###
gulp.task 'build', ['jade', 'coffee', 'styl', 'assets']
gulp.task 'deploy', ['build', 'gh-pages']
gulp.task 'default', ['build', 'watch']