-
Notifications
You must be signed in to change notification settings - Fork 5
/
Gruntfile.coffee
173 lines (164 loc) · 5.04 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
169
170
171
172
173
module.exports = (grunt) ->
jasmineRequireTemplate = require 'grunt-template-jasmine-requirejs'
jasmineIstanbulTemplate = require 'grunt-template-jasmine-istanbul'
jasmineSpecRunner = 'spec-runner.html'
coverageSpecRunner = 'coverage-runner.html'
sourcePath = 'src/js/**/*.js'
documentation = 'doc'
testRequireConfig = 'test/js/js-test-require-config.js'
specs = 'test/js/spec/**/*.js'
styles = 'bower_components/hp-autonomy-js-testing-utils/src/css/bootstrap-stub.css'
serverPort = 8000
host = "http://localhost:#{serverPort}/"
helpers = 'bower_components/hp-autonomy-js-testing-utils/src/js/jasmine-custom-matcher.js'
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
clean: [
jasmineSpecRunner
coverageSpecRunner
'bin'
'.grunt'
documentation
]
connect:
server:
options:
port: serverPort
jasmine:
test:
src: sourcePath
options:
helpers: helpers
host: host
keepRunner: true
outfile: jasmineSpecRunner
specs: specs
styles: styles
template: jasmineRequireTemplate
templateOptions:
requireConfigFile: testRequireConfig
coverage:
src: sourcePath
options:
helpers: helpers
host: host
keepRunner: true
outfile: coverageSpecRunner
specs: specs
styles: styles
template: jasmineIstanbulTemplate
templateOptions:
coverage: 'bin/coverage/coverage.json'
replace: false
report:
type: 'text'
template: jasmineRequireTemplate
templateOptions:
requireConfigFile: testRequireConfig
requireConfig:
config:
instrumented: {
src: grunt.file.expand(sourcePath)
}
callback: () ->
define('instrumented', ['module'], (module) ->
module.config().src
)
require ['instrumented'], (instrumented) ->
oldLoad = requirejs.load
requirejs.load = (context, moduleName, url) ->
if url.substring(0, 1) == '/'
url = url.substring 1
else if url.substring(0, 2) == './'
url = url.substring 2
# redirect
if instrumented.indexOf(url) > -1
url = './.grunt/grunt-contrib-jasmine/' + url
return oldLoad.apply(this, [context, moduleName, url])
return
return
jshint:
all: [
sourcePath
specs
],
options:
asi: true
bitwise: true
browser: true
camelcase: true
curly: true
devel: true
eqeqeq: true
es3: true
expr: true
forin: true
freeze: true
jquery: true
latedef: true
laxbreak: true
newcap: true
noarg: true
noempty: true
nonbsp: true
undef: true
unused: true
validthis: true
globals:
define: false
_: false
expect: false
it: false
require: false
describe: false
sinon: false
beforeEach: false
afterEach: false
jasmine: false
runs: false
waits: false
waitsFor: false
spyOn: false
xit: false
xdescribe: false
coffeelint:
app: [
'Gruntfile.coffee'
]
options:
max_line_length:
level: 'ignore'
jsdoc:
dist:
src: ['src/**/*.js', 'README.md']
options:
destination: documentation
template: 'node_modules/ink-docstrap/template'
configure: 'jsdoc.conf.json'
'gh-pages':
'default':
src: '**/*'
options:
base: 'doc'
message: 'Update documentation'
travis:
src: '**/*'
options:
base: 'doc'
message: 'Update documentation'
repo: '[email protected]:' + process.env.TRAVIS_REPO_SLUG
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-contrib-connect'
grunt.loadNpmTasks 'grunt-contrib-jasmine'
grunt.loadNpmTasks 'grunt-contrib-jshint'
grunt.loadNpmTasks 'grunt-coffeelint'
grunt.loadNpmTasks 'grunt-gh-pages'
grunt.loadNpmTasks 'grunt-jsdoc'
grunt.registerTask 'default', ['lint', 'connect:server', 'jasmine:test', 'jasmine:coverage']
grunt.registerTask 'test', ['connect:server', 'jasmine:test']
grunt.registerTask 'browser-test', ['connect:server:keepalive']
grunt.registerTask 'coverage', ['connect:server', 'jasmine:coverage']
grunt.registerTask 'lint', ['jshint', 'coffeelint']
grunt.registerTask 'doc', ['jsdoc']
grunt.registerTask 'push-doc', ['doc', 'gh-pages:default']
grunt.registerTask 'push-doc-travis', ['doc', 'gh-pages:travis']