forked from angular/angular-seed
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgrunt.coffee
executable file
·200 lines (159 loc) · 5.47 KB
/
grunt.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
module.exports = (grunt)->
###############################################################
# Constants
###############################################################
# Main src dirs
SRC_ROOT= 'src/main'
SRC_HTML = "#{SRC_ROOT}/html/**"
SRC_CSS = "#{SRC_ROOT}/css/**"
SRC_LIB = "#{SRC_ROOT}/lib/**"
SRC_COFFEE_DIR= "#{SRC_ROOT}/coffee"
SRC_COFFEE= "#{SRC_COFFEE_DIR}/**"
SRC_JS = "#{SRC_ROOT}/js/**"
# Test src dirs
TEST_ROOT= 'src/test'
TEST_HTML = "#{SRC_ROOT}/html/**"
TEST_LIB = "#{TEST_ROOT}/lib/**"
TEST_COFFEE_DIR= "#{TEST_ROOT}/coffee"
TEST_COFFEE= "#{TEST_COFFEE_DIR}/**"
TEST_JS = "#{TEST_ROOT}/js/**"
TEST_CONFIG = "target/test/js/config/testacular.conf.js"
TEST_E2E_CONFIG = "target/test/js/config/testacular-e2e.conf.js"
###############################################################
# Config
###############################################################
grunt.initConfig
clean:
main: 'target/main'
test: 'target/test'
copy:
# handles html, css, and imgs, which (right now) don't go through any processing
static:
files:
"target/main/": SRC_HTML
"target/test/": TEST_HTML
"target/main/css/": SRC_CSS
# handles libs
libs:
files:
"target/main/lib/": SRC_LIB
"target/test/lib/": TEST_LIB
# all js
js:
files:
"target/main/js/": SRC_JS
"target/test/js/": TEST_JS
# note no copy coffee - coffeescript files are 'copied' by the compiler
# Will overwrite any javascript with the same name, if it exists
coffee:
main:
options:
preserve_dirs: true
base_path: SRC_COFFEE_DIR
bare: true
src: SRC_COFFEE
dest: 'target/main/js/'
test:
options:
preserve_dirs: true
base_path:TEST_COFFEE_DIR
bare: true
src: TEST_COFFEE
dest: 'target/test/js/'
# If you don't want to use the coffeescript grunt file.
###
jsGruntConfig:
options:
bare: true
files:
'grunt.js': 'grunt.coffee'
###
# copied jqueryui's config, + browser
jshint:
options:
curly: true
eqnull: true
eqeqeq: true
expr: true
latedef: true
noarg: true
onevar: true
smarttabs: true
trailing: true
undef: true
browser:true
globals:
angular: true
lint:
main: SRC_JS
test: TEST_JS
server:
base: 'target/main'
watch:
coffee_main:
files: SRC_COFFEE
tasks: 'coffee:main'
coffee_test:
files: TEST_COFFEE
tasks: 'coffee:test'
copy_static:
files: [SRC_HTML, TEST_HTML, SRC_CSS]
tasks: 'copy:static'
copy_lib:
files: [SRC_LIB, TEST_LIB]
tasks: 'copy:lib'
copy_js:
files: [SRC_JS, TEST_JS]
tasks: 'copy:js'
# test anytime src changes. Runs after copy / compile!
test:
files: [SRC_JS, TEST_JS, SRC_COFFEE, TEST_COFFEE]
tasks: 'test'
###
# Disabled as angular-seed fails linting
lint:
files: [SRC_JS, TEST_JS]
tasks: 'lint'
###
##############################################################
# Custom Tasks
###############################################################
grunt.registerTask('testServer', 'Start Testacular server', ()->
testacular = require('testacular');
testacular.server.start(configFile: TEST_CONFIG) # starts async
)
grunt.registerTask('test', 'Run testacular tests', () ->
# TODO See why we can't get testacular.runner.run working
if process.platform == 'win32'
testCmd = 'node_modules\\.bin\\testacular.cmd'
else
testCmd = 'node_modules/.bin/testacular'
travisArgs = ['start', '--single-run', '--no-auto-watch', '--reporter=dots', '--browsers=Firefox']
testArgs = if process.env.TRAVIS then travisArgs else ['run']
specDone = this.async()
child = grunt.utils.spawn(
{cmd: testCmd, args: testArgs}, (err, result, code) ->
if code
grunt.log.error("Test failed...", code)
specDone()
)
child.stdout.pipe(process.stdout)
child.stderr.pipe(process.stderr)
)
##############################################################
# Dependencies
###############################################################
grunt.loadNpmTasks('grunt-coffee');
grunt.loadNpmTasks('grunt-contrib-copy')
grunt.loadNpmTasks('grunt-contrib-clean')
###############################################################
# Alias tasks
###############################################################
# commenting out lint - angular-seed fails :(
# grunt.registerTask('build_js', 'lint copy')
grunt.registerTask('build_js', 'copy')
grunt.registerTask('build_coffee', 'copy coffee')
# Uncomment only one
grunt.registerTask('build', 'build_js')
#grunt.registerTask('build', 'build_coffee')
grunt.registerTask('default', 'clean build server testServer watch')