forked from satellite-game/Satellite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
168 lines (141 loc) · 4.53 KB
/
Gruntfile.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
module.exports = (grunt) ->
# Order of concatonation/minification
includeOrder = require './include.conf'
grunt.initConfig
pkg: grunt.file.readJSON('package.json')
# TESTING
# ================
# client-side:
# ----------------
karma:
unit:
configFile: 'karma.conf.js'
autoWatch: false
singleRun: false
background: true
travis:
configFile: 'karma.conf.js'
autoWatch: false
singleRun: true
browsers: ['sl_chrome_OSX9']
# server-side:
# ----------------
# name matters for the 'mocha-chai-sinon' module
'mocha-chai-sinon':
build:
src: ['./tests/server/**/*.js']
options:
ui: 'bdd'
reporter: 'spec'
coverage:
src: ['./tests/server/**/*.js']
options:
ui: 'bdd'
reporter: 'html-cov'
quiet: true
# filter: '/foo/foo1/' # which files are you testing for coverage?
captureFile: './coverage/MCS_server_coverage.html'
# INITIALIZING & PROD-READY
# ==========================
open:
client:
path: 'http://localhost:1337'
clean:
build: 'build/'
copy:
client:
expand: true
cwd: 'client/'
src: ['**', '!**/styl/**', '!**/classes/**']
dest: 'build/client/'
uglify:
options:
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today(\'yyyy-mm-dd\') %>\n' + '* <%= pkg.homepage %>/\n' + '* Copyright (c) <%= grunt.template.today(\'yyyy\') %> <%= pkg.author %>; Licensed <%= pkg.license %> */\n'
mangle:
except: ['_super']
client:
files:
'build/client/game/s.js': [includeOrder]
concat:
client:
src: [includeOrder]
dest: 'build/client/game/s.js'
# LINTING & COMPILE
# =================
jshint:
options:
jshintrc: '.jshintrc'
gruntfile: ['Gruntfile.js']
server: ['server/**/*.js']
client: ['client/**/*.js', '!**/models/**', '!**/lib/**']
tests: ['tests/**/*.js', '!tests/oculus-testing-playground/**/*.js']
stylus:
compile:
options:
# nib
paths: ['node_modules/', 'client/game/styl/'] # Individual components
files:
'build/client/game/s.css': 'client/game/styl/s.styl'
# WATCH
# =================
watch:
gruntfile:
files: ['Gruntfile.js']
tasks: ['jshint:gruntfile']
options:
livereload: true
server:
files: ['server/**/*.js']
tasks: ['server']
options:
livereload: true
client:
files: ['client/**']
tasks: ['client']
options:
livereload: true
test:
files: [ 'client/**', 'tests/**/*.js' ]
tasks: [ 'mocha-chai-sinon', 'karma:unit:run' ]
# RUN CONCURRENTS
# =================
concurrent:
target:
tasks: ['nodemon', 'watch', 'delayed-open'],
options:
logConcurrentOutput: true
# INIT SERVER
# =================
nodemon:
dev: {}
grunt.registerTask 'delayed-open', 'open the local host after the server has spun up.', ->
setInterval grunt.task.run('open'), 3000
# DEPENDENCIES
# =================
# Loading dependencies
# for pkg of grunt.file.readJSON("package.json").devDependencies
# grunt.loadNpmTasks pkg if pkg isnt "grunt" and pkg.indexOf("grunt") is 0
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-contrib-concat'
grunt.loadNpmTasks 'grunt-contrib-copy'
grunt.loadNpmTasks 'grunt-contrib-jshint'
grunt.loadNpmTasks 'grunt-contrib-stylus'
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-concurrent'
grunt.loadNpmTasks 'grunt-nodemon'
grunt.loadNpmTasks 'grunt-open'
grunt.loadNpmTasks 'grunt-karma'
grunt.loadNpmTasks 'grunt-mocha-chai-sinon'
# REGISTER
# =================
grunt.registerTask 'travisCI', ['jshint:server',
'jshint:client',
'jshint:tests',
'karma:travis',
'mocha-chai-sinon']
grunt.registerTask 'test', ['karma:unit:start', 'watch:test']
grunt.registerTask 'server', ['jshint:server']
grunt.registerTask 'client', ['jshint:client', 'copy:client', 'concat', 'stylus']
grunt.registerTask 'client-prod', ['client', 'uglify']
grunt.registerTask 'default', ['server', 'client', 'concurrent']