-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
54 lines (45 loc) · 1.52 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
/**
* This method will load all task configurations dynamically from the
* specified directory.
*
* @param {String} path The path to the task configuration settings files
* @returns {{}}
*/
function loadTaskConfigurations(path){
var glob = require('glob');
var configs = {};
var key;
//Gets all task config items and imports them to the configs object
glob.sync('*', {cwd: path}).forEach(function(filename){
key = filename.replace(/\.js$/, '');
configs[key] = require(process.cwd() + "/" + path + filename);
});
return configs;
}
/**
* Kick off the Grunt module
* @param {Object} grunt The Grunt object
*/
module.exports = function(grunt){
//Run initial Grunt config
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
directories: "<%=pkg.directories %>"
});
//Load all task configurations
var taskConfigurations = loadTaskConfigurations(grunt.config.get("pkg.directories.gruntTaskConfig"));
//Add those task configurations to the grunt config
for(var task in taskConfigurations){
grunt.config.set(task, taskConfigurations[task]);
}
//Gets all defined tasks from the defined tasks directory
grunt.loadTasks(grunt.config.get("pkg.directories.gruntTasks"));
//Load all tasks from devDependencies.
//See load-grunt-tasks documentation for specific customization options.
require("load-grunt-tasks")(grunt, {
pattern: [
"grunt-*",
"assemble"
]
});
};