-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathGruntfile.coffee
More file actions
executable file
·223 lines (205 loc) · 5.28 KB
/
Copy pathGruntfile.coffee
File metadata and controls
executable file
·223 lines (205 loc) · 5.28 KB
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
###
scroll-proxy's Gruntfile
Author: Matheus Kautzmann
Description:
Build the project files, three main modes are available:
- grunt watch = useful while developing features or fixing bugs, keeps
running CoffeeScript compilation.
- grunt demo = Spawns a demo server where you can debug ScrollProxy.
- grunt test = Runs local tests and coverage checks.
- grunt build = Builds the whole project leaving the CommonJS modules on
lib folder and full packaged ready-to-use code on dist folder.
Also, there are some individual grunt tasks, for more info run `grunt help`
###
module.exports = (grunt) ->
grunt.initConfig({
pkg: grunt.file.readJSON('package.json')
# Lint all the CoffeeScript files
coffeelint: {
app: {
files: {
src: ['src/*.coffee', 'Gruntfile.coffee']
}
}
test: {
files: {
src: ['test/*.coffee']
}
}
options: {
configFile: 'coffeelint.json'
}
}
# Browserify bundles
browserify: {
standalone: {
src: ['src/*.coffee']
dest: 'dist/<%= pkg.name %>.min.js'
options: {
transform: ['coffeeify', 'uglifyify']
browserifyOptions: {
standalone: 'ScrollProxy'
extensions: '.coffee'
}
banner: '/*<%= pkg.name %>@<%= pkg.version %>*/'
}
}
demo: {
src: ['src/*.coffee', 'demo/*.coffee']
dest: 'demo/<%= pkg.name %>.js'
options: {
transform: ['coffeeify']
browserifyOptions: {
extensions: '.coffee'
debug: true
}
}
}
test: {
src: ['test/*.coffee']
dest: 'test/testBundle.js'
options: {
transform: ['browserify-coffee-coverage']
browserifyOptions: {
extensions: '.coffee'
debug: true
}
}
}
}
# Compile Coffee for NPM bundle
coffee: {
main: {
files: {
'dist/scroll-proxy.js': 'src/ScrollProxy.coffee'
'dist/SUtil.js': 'src/SUtil.coffee'
}
}
options: {
bare: true
banner: '/*<%= pkg.name %>@<%= pkg.version %>*/'
}
}
# Run tests using Mocha locally
mochify: {
test: {
options: {
reporter: 'spec'
extension: '.coffee'
transform: 'coffeeify'
cover: true
}
src: ['test/*.coffee']
}
}
# Generate documentation with Codo
codo: {
app: {
src: ['src/*.coffee']
options: {
name: '<%= pkg.name %>'
output: './docs'
title: '<%= pkg.name %>\'s Documentation'
}
}
}
# Clean all builds, get back to default state you were when cloning
clean: [
'dist'
'docs'
'demo/scroll-proxy.js'
'test/testBundle.js'
'bower_components'
'node_modules'
]
# Watch tasks to run while developing
watch: {
options: {
spawn: true
}
coffeelint: {
files: ['src/*.coffee', 'Gruntfile.coffee']
tasks: ['coffeelint']
}
browserifyDemo: {
files: ['src/*.coffee', 'demo/*.coffee']
tasks: ['browserify:demo']
}
browserifyTest: {
files: ['src/*.coffee', 'test/*.coffee']
tasks: ['browserify:test']
}
}
# Run connect server for testing purposes
connect: {
server: {
options: {
port: 8080
base: '.'
}
}
}
# Run demo server and open demo page
'http-server': {
demo: {
root: './demo'
port: 3000
ext: 'html'
runInBackground: false
openBrowser: true
}
}
# Runs browser tests on Sauce Labs (only Circle CI must run it)
'saucelabs-mocha': {
all: {
options: {
username: process.env.SAUCE_USERNAME
key: process.env.SAUCE_ACCESSKEY
urls: ['localhost:8080/test/index.html']
testname: 'scroll-proxy'
build: 'build-ci' + process.env.CIRCLE_BUILD_NUM
pollInterval: 5000
'max-duration': 500
maxRetries: 1
browsers: grunt.file.readJSON('browserSupport.json').browsers
}
}
}
})
# Load grunt tasks
grunt.loadNpmTasks('grunt-browserify')
grunt.loadNpmTasks('grunt-codo')
grunt.loadNpmTasks('grunt-coffeelint')
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.loadNpmTasks('grunt-contrib-coffee')
grunt.loadNpmTasks('grunt-mochify')
grunt.loadNpmTasks('grunt-contrib-connect')
grunt.loadNpmTasks('grunt-contrib-watch')
grunt.loadNpmTasks('grunt-http-server')
grunt.loadNpmTasks('grunt-saucelabs')
# Set up the task aliases
grunt.registerTask('lint', ['coffeelint:app', 'coffeelint:test'])
grunt.registerTask('renew', ['clean'])
grunt.registerTask('docs', ['codo'])
grunt.registerTask('test', [
'lint'
'mochify:test'
])
grunt.registerTask('demo', [
'browserify:demo'
'http-server'
])
grunt.registerTask('build', [
'test'
'coffee'
'browserify:standalone'
'docs'
])
if process.env.CI
grunt.registerTask('ci', [
'test'
'browserify:test'
'connect'
'saucelabs-mocha'
])
grunt.registerTask('default', ['build'])