-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.coffee
141 lines (125 loc) · 3.24 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
module.exports = (grunt) ->
# Load grunt tasks automatically
require('load-grunt-tasks') grunt
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
# Empty folders to start fresh
clean:
all:
files: [
dot: true
src: ['build', 'dist']]
# Compiles CoffeeScript to JavaScript
coffee:
options:
sourceMap: true
app:
files: [{
expand: true
cwd: 'src'
src: '**/*.coffee'
dest: 'build'
ext: '.js'
}]
test:
files: [
expand: true
cwd: 'test'
src: '**/*.coffee'
dest: 'build/test'
ext: '.js']
# Watches files for changes in interactive mode
watch:
options:
livereload: true
gruntfile:
files: ['Gruntfile.coffee']
tasks: ['mochaTest:all','coffeelint:gruntfile']
coffee:
files: ['index.html', 'src/**/*.coffee']
tasks: ['coffee:app','coffeelint:src','mochaTest:all']
coffeeTest:
files: ['test/**/*.coffee']
tasks: ['coffee:test','coffeelint:test','mochaTest:all']
mochaTest:
all:
src: ['test/*.coffee']
options:
reporter: 'spec'
spawn:
dist:
directory: './build'
command: 'node'
commandArgs: ['server.js']
opts:
cwd: './build'
coffeelint:
options:
no_trailing_whitespace: level: 'error'
arrow_spacing: level: 'error'
cyclomatic_complexity: level: 'warn'
empty_constructor_needs_parens: level: 'error'
line_endings: level: 'error'
no_empty_functions: level: 'warn'
no_empty_param_list: level: 'error'
no_interpolation_in_single_quotes: level: 'error'
no_stand_alone_at: level: 'error'
no_unnecessary_double_quotes: level: 'error'
no_unnecessary_fat_arrows: level: 'error'
space_operators: level: 'error'
gruntfile:
files:
src: ['Gruntfile.coffee']
src:
files:
src: ['src/*.coffee']
test:
files:
src: ['test/*.coffee']
useminPrepare:
html: 'index.html'
options:
dest: 'dist'
flow:
steps:
js: ['concat']
css: ['concat', 'cssmin']
post: {}
copy:
html:
files:
[{src: 'index.html', dest: 'dist/'}]
usemin:
html: 'dist/index.html'
concurrent:
options:
logConcurrentOutput: true
limit: 5
serve:
tasks: ['spawn:dist', 'watch']
# Run the tests
grunt.registerTask 'test', (target) ->
grunt.task.run [
'coffee'
'coffeelint:src'
'coffeelint:test'
'mochaTest']
# Run the server and watch for file changes
grunt.registerTask 'serve', (target) ->
if target == 'test'
grunt.task.run ['test', 'watch']
else
grunt.task.run ['coffee', 'concurrent:serve']
# Prepares application for production
grunt.registerTask 'build', [
'clean'
'coffee']
grunt.registerTask 'dist', [
'coffee'
'useminPrepare'
'concat:generated'
'cssmin:generated'
'copy:html'
'usemin']
# Default task
grunt.registerTask 'default', ['build', 'test']