-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGruntfile.js
186 lines (171 loc) · 4.39 KB
/
Gruntfile.js
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
/*
* Gruntfile for Minibus.js
*
* Copyright (c) 2014 Akseli Palen
* Licensed under the MIT license.
*
* Installation
* npm install # to install package
* npm install -g grunt-cli # may require sudo
*/
module.exports = function(grunt) {
'use strict';
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Meta options for conveniency
meta: {
banner: '\
/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n\
* <%= pkg.homepage %>\n\
*\n\
* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> <<%= pkg.author.email %>>;\n\
* Licensed under the <%= pkg.license.type %> license */\n\n'
},
// Merge source files
concat: {
options: {
separator: '\n\n'
},
dist: {
options: {
banner: '<%= meta.banner %>'
},
src: [
'src/intro.js',
'src/minibus.js',
'src/identity.js',
'src/version.js',
'src/outro.js'
],
dest: '<%= pkg.name %>.js'
}
},
// Minify the source code
uglify: {
options: {
report: 'gzip',
banner: '<%= meta.banner %>'
},
dist: {
options: {
sourceMap: '<%= pkg.name %>.min.map'
},
files: {
'<%= pkg.name %>.min.js': ['<%= pkg.name %>.js'],
}
}
},
// Check for optimisations and errors
// http://www.jshint.com/docs/options/
jshint: {
options: {
// Enforcing options
camelcase: true,
curly: true,
eqeqeq: true,
forin: true,
freeze: true,
immed: true,
//indent: 2,
maxlen: 80,
newcap: false,
noarg: true,
//noempty: true,
nonew: true,
plusplus: true,
quotmark: 'single',
undef: true,
//unused: true, // warn about unused variables
strict: true,
trailing: true,
// Relaxing options, supresses warnings
//asi: true, missing semicolons
//boss: true, assignments in weird places
//eqnull: true,
//evil: true,
//expr: true, // expressions in weird places
// Environment options
browser: true,
jquery: true,
node: true,
globals: {
'_': false, // any effect being true or false?
define: false // ?
}
},
dist: {
src: ['<%= pkg.name %>.js']
}
},
// Update version in the sources
replace: {
dist: {
options: {
patterns: [
{
match: /\.version\s*=\s*'\d+\.\d+\.\d+'/,
replacement: ".version = '<%= pkg.version %>'",
expression: true // use RegExp
}
]
},
files: [
{
src: ['src/version.js'],
dest: 'src/version.js'
}
]
},
readme: {
options: {
patterns: [
{
match: />v\d+\.\d+\.\d+</,
replacement: ">v<%= pkg.version %><",
expression: true // use RegExp
}
]
},
files: [
{
src: ['README.md'],
dest: 'README.md'
}
]
}
},
qunit: {
dist: {
options: {
timeout: 3000,
urls: [
'http://localhost:8000/test/test-suite.html'
]
},
}
},
// Start server for QUnit tests.
connect: {
server: {
options: {
port: 8000,
base: '.'
}
}
}
});
// Load tasks
grunt.loadNpmTasks('grunt-contrib-concat'); // For merging files together
grunt.loadNpmTasks('grunt-contrib-uglify'); // For minifying
grunt.loadNpmTasks('grunt-contrib-jshint'); // For sanity testing
grunt.loadNpmTasks('grunt-contrib-qunit'); // For functional testing
grunt.loadNpmTasks('grunt-contrib-connect'); // For functional test server
grunt.loadNpmTasks('grunt-replace'); // For adding versions
// Default task(s).
grunt.registerTask('default', ['build']);
grunt.registerTask('build', ['replace', 'concat', 'uglify', 'test']);
grunt.registerTask('test', ['test:syntax', 'test:function']);
grunt.registerTask('test:syntax', ['jshint']);
grunt.registerTask('test:function', ['connect', 'qunit']);
};