forked from opengovfoundation/madison
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
49 lines (41 loc) · 1.24 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
/**
* Modular Gruntfile setup borrowed from SailsJS
* All tasks are loaded from the `tasks` directory.
*/
module.exports = function (grunt) {
var includeAll;
try{
includeAll = require('include-all');
} catch (e0) {
console.error('Could not find `include-all` module.');
console.error('Skipping grunt tasks...');
console.error('To fix this, please run:');
console.error('npm install include-all --save');
console.error();
grunt.registerTask('default', []);
return;
}
function loadTasks(relPath) {
return includeAll({
dirname: require('path').resolve(__dirname, relPath),
filter: /(.+)\.js$/
}) || {};
}
function invokeConfigFn(tasks) {
for (var taskName in tasks) {
if (tasks.hasOwnProperty(taskName)) {
tasks[taskName](grunt);
}
}
}
// Load task functions
var taskConfigurations = loadTasks('./tasks/config'),
registerDefinitions = loadTasks('./tasks/register');
// ensure that a default task exists
if (!registerDefinitions.default) {
registerDefinitions.default = function (grunt) { grunt.registerTask('default', []); };
}
// Run task functions to configure Grunt
invokeConfigFn(taskConfigurations);
invokeConfigFn(registerDefinitions);
};