-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGruntfile.js
151 lines (133 loc) · 4.09 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
/*
* grunt-generate-configs
* https://github.com/creynders/grunt-generate-configs
*
* Copyright (c) 2014 Camille Reynders
* Licensed under the MIT license.
*
* Just in case you're wondering why I'm not eating my own dog food, i.e. using load-grunt-configs here, it's because
* this grunt file is used to test the correct functioning of the grunt-generate-configs task.
*/
'use strict';
module.exports = function(grunt){
var loadGruntConfigs = require('load-grunt-configs');
// Actually load this plugin's task(s).
grunt.loadTasks('tasks');
// These plugins provide necessary tasks.
require('jit-grunt')(grunt);
// Project configuration.
grunt.initConfig({
jshint : {
all : [
'Gruntfile.js', 'tasks/*.js', '<%=nodeunit.tests%>'
],
options : {
jshintrc : '.jshintrc'
}
},
// Before generating any new files, remove any previously-created files.
clean : {
config : [
'config'
],
tmp : [
'.tmp'
]
},
// Unit tests.
nodeunit : {
tests : [
'tests/*_test.js'
]
},
markdown : {
docs : {
files : [
{
expand : true,
src : 'README.md',
dest : '.tmp',
ext : '.html'
}
],
options : {
markdownOptions : {
gfm : true
}
}
}
},
watch : {
docs : {
files : [
'README.md'
],
tasks : [
'clean:tmp', 'markdown:docs'
],
options : {
livereload : true
}
},
livereload : {
options : {
livereload : '<%= connect.options.livereload %>'
},
files : [
'.tmp/{,*/}*.html'
]
}
},
connect : {
options : {
port : 9000,
livereload : 35729,
// Change this to '0.0.0.0' to access the server from outside
hostname : 'localhost'
},
livereload : {
options : {
open : true,
base : [
'.tmp'
]
}
}
}
});
function generateConfigs(flags){
grunt.task.run([
'set_options:' + flags, 'clean:config', 'generate_configs', 'nodeunit', 'load-grunt-configs', 'clean:config'
]);
}
grunt.registerTask('load-grunt-configs', function(){
loadGruntConfigs(grunt);
});
// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
//grunt test; grunt test --type=js; grunt test --target=foo; grunt test --type=yaml; grunt test --type=coffee
grunt.registerTask('test', function(){
grunt.loadTasks('tests/support');
generateConfigs('');
generateConfigs('--target=testConfig');
generateConfigs('--type=js');
generateConfigs('--type=json');
generateConfigs('--type=yaml');
generateConfigs('--type=yml');
generateConfigs('--type=coffee');
generateConfigs('--type=cson');
generateConfigs('--cson');
generateConfigs('--coffee');
generateConfigs('--yaml');
generateConfigs('--yml');
generateConfigs('--js');
generateConfigs('--json');
});
grunt.registerTask('preview', [
'clean:tmp', 'markdown:docs', 'connect:livereload', 'watch'
]);
// By default, lint and run all tests.
grunt.registerTask('default', [
'jshint', 'test'
]);
};