-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGruntfile.coffee
136 lines (120 loc) · 2.67 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
'use strict'
module.exports = (grunt) ->
# load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach((contrib) ->
grunt.log.ok([contrib + " is loaded"])
grunt.loadNpmTasks(contrib)
)
config =
dist: 'dist'
src: 'src'
distTest: 'test/dist'
srcTest: 'test/src'
# Project configuration.
grunt.initConfig
config: config
clean:
dist:
files: [
dot: true
src: [
'<%= config.dist %>/*'
'<%= config.distTest %>/*'
'!<%= config.dist %>/.git*'
]
]
coffee:
dist:
files: [
{
expand: true,
cwd: '<%= config.src %>'
src: '{,*/}*.coffee'
dest: '<%= config.dist %>'
ext: '.js'
},
{
expand: true,
cwd: '<%= config.src %>'
src: 'static/js/{,*/}*.coffee'
dest: '<%= config.dist %>'
ext: '.js'
}
]
test:
files: [
expand: true
cwd: '<%= config.srcTest %>'
src: '{,*/}*.spec.coffee'
dest: '<%= config.distTest %>'
ext: '.spec.js'
]
jshint:
options:
jshintrc: '.jshintrc'
gruntfile:
src: 'Gruntfile.js'
watch:
gruntfile:
files: '<%= jshint.gruntfile.src %>'
tasks: ['jshint:gruntfile']
dist:
files: [
'<%= config.src %>/*'
'<%= config.src %>/static/js/*'
]
tasks: ['coffee:dist', 'simplemocha:backend']
test:
files: '<%= config.srcTest %>/specs/*'
tasks: ['coffee:test', 'simplemocha:backend']
simplemocha:
options:
globals: [
'sinon'
'chai'
'should'
'expect'
'assert'
'AssertionError'
]
timeout: 3000
ignoreLeaks: false
# grep: '*.spec'
ui: 'bdd'
reporter: 'spec'
backend:
src: [
# add chai and sinon globally
'test/support/globals.js'
# tests
'test/dist/**/*.spec.js'
]
grunt.registerTask 'coverageBackend', 'Test backend files as well as code coverage.', () ->
done = @async()
path = './test/support/runner.js'
options =
cmd: 'istanbul'
grunt: false
args: [
'cover'
'--default-excludes'
'-x', 'app/**'
'--report', 'lcov'
'--dir', './coverage/backend'
path
]
opts:
# preserve colors for stdout in terminal
stdio: 'inherit'
doneFunction = (error, result) ->
if (result && result.stderr)
process.stderr.write(result.stderr)
if (result && result.stdout)
grunt.log.writeln(result.stdout)
# abort tasks in queue if there's an error
done(error)
grunt.util.spawn(options, doneFunction)
# Default task.
grunt.registerTask('default', ['coffee', 'jshint'])
grunt.registerTask('test', ['clean', 'coffee', 'simplemocha:backend'])
grunt.registerTask('coverage', ['clean', 'coffee', 'coverageBackend'])