-
Notifications
You must be signed in to change notification settings - Fork 8
/
Gruntfile.coffee
138 lines (118 loc) · 3.73 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
module.exports = ( grunt ) ->
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-concat'
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-contrib-cssmin'
grunt.loadNpmTasks 'grunt-text-replace'
grunt.loadNpmTasks 'grunt-contrib-handlebars'
grunt.loadNpmTasks 'grunt-casperjs'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-coffeelint'
grunt.loadNpmTasks 'grunt-exec'
grunt.loadNpmTasks 'grunt-parallel'
# Project configuration.
grunt.initConfig
meta:
banner: """
/* IsValid
* http://isvalid.org/
* Copyright (c) <%= grunt.template.today("yyyy") %>
* Evan Solomon; Licensed MIT
*/
"""
concat:
options:
banner: '<%= meta.banner %>'
dist:
src : [
'js/vendor/jquery.js'
'js/vendor/underscore.js'
'js/vendor/handlebars.runtime.js'
'js/templates/*.js'
'js/src/concon.js'
'js/src/app.js'
]
dest : 'static/js/scripts.js'
uglify:
options:
banner: '<%= meta.banner %>'
dist:
src : '<%= concat.dist.dest %>'
dest : 'static/js/scripts.min.js'
bookmarklet:
src : 'js/bookmarklet/bookmarklet.js'
dest : 'js/bookmarklet/bookmarklet.min.js'
coffee:
app:
expand : true
cwd : 'js/src'
src : '*.coffee'
dest : 'js/src/'
ext : '.js'
bookmarklet:
files:
'js/bookmarklet/bookmarklet.js' : 'js/bookmarklet/bookmarklet.coffee'
cssmin:
options:
banner: '<%= meta.banner %>'
keepSpecialComments: 0
compress:
files:
'static/css/styles.min.css' : ['css/bootstrap.css', 'css/isvalid.css'],
'static/css/embed.min.css' : 'css/embed.css'
replace:
bookmarklet:
src : ['templates/footer.php', 'README.md']
overwrite : true
replacements : [
from : /javascript:[^\n']+/
to : ->
# Use the last line of the minified JS
bookmarklet = grunt.file.read( 'js/bookmarklet/bookmarklet.min.js' ).split( '\n' ).pop()
"javascript:#{bookmarklet}"
]
handlebars:
options:
namespace : 'Handlebars.templates'
processName : ( filename ) ->
filename.match( /([a-z]+)\.handlebars/ ).pop()
compile:
files:
'js/templates/results.js' : 'js/templates/results.handlebars'
'js/templates/error.js' : 'js/templates/error.handlebars'
casperjs:
files: ['tests/casperjs/**/*.coffee']
options:
async:
parallel: true
watch:
scripts:
files: ['js/**/*.coffee', 'js/vendor/*']
tasks: ['coffee', 'concat', 'uglify', 'replace']
options:
interrupt: true
templates:
files: 'js/**/*.handlebars'
tasks: ['handlebars', 'concat', 'uglify']
styles:
files: 'css/**/*'
tasks: ['cssmin']
coffeelint:
all:
files: '**/*.coffee'
options:
no_tabs: false
no_empty_param_list: true
exec:
start_test_server:
command: 'php -S localhost:8080 >/dev/null 2>&1 &'
kill_test_server:
command: "ps aux | grep 'php -S localhost:8080' | grep -v grep | awk '{print $2}' | xargs kill"
parallel:
compile:
grunt: true
tasks: ['coffee', 'handlebars', 'cssmin']
# Default task.
grunt.registerTask 'default', ['coffeelint', 'parallel:compile', 'concat', 'uglify', 'replace']
grunt.registerTask 'test', ['exec:start_test_server', 'casperjs', 'exec:kill_test_server']
grunt.registerTask 'all', ['default', 'test']