forked from ChtiJS/chtijs.francejs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
executable file
·83 lines (59 loc) · 2.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
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
module.exports = function(grunt) {
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
var env = process.env.NODE_ENV || 'dev';
var _ = require('lodash');
/*** External config & tasks filepaths ***/
//we have 1 base config, and possibly many module-specific config
var configLocations = [
'./grunt-config/base_config.js',
'./grunt-config/**/config.js',
'./grunt-config/**/*-config.js'
];
//we have 1 base tasks definition, and possibly many module-specific config
var tasksLocations = [
'./grunt-config/base_tasks.js',
'./grunt-config/**/tasks.js',
'./grunt-config/**/*-tasks.js'
];
/***************** External configuration management ***********************************/
var configFiles = grunt.file.expand({
filter: "isFile"
}, configLocations );
grunt.verbose.writeln('Gathering external configuration files'.underline.green);
grunt.verbose.writeln("configFiles : " + grunt.log.wordlist(configFiles, {
separator: ', ',
color: 'cyan'
}));
var configArray = configFiles.map(function(file) {
grunt.verbose.writeln("=> importing : " + file);
return require(file)(grunt, env);
});
var config = {};
configArray.forEach(function(element) {
config = _.merge(config, element);
});
grunt.verbose.subhead('* Generated config file: *');
grunt.verbose.writeln(JSON.stringify(config, undefined, 2));
grunt.initConfig(config);
/** Task loading & registering **/
// We load grunt tasks listed in package.json file
require('load-grunt-tasks')(grunt);
/** External tasks registering **/
grunt.verbose.writeln('Gathering external task files'.underline.green);
var taskFiles = grunt.file.expand({
filter: "isFile"
}, tasksLocations);
grunt.verbose.writeln("task files : " + grunt.log.wordlist(taskFiles, {
separator: ', ',
color: 'cyan'
}));
taskFiles.forEach(function(path) {
grunt.verbose.writeln("=> loading & registering : " + path);
require(path)(grunt);
});
//write the generated configuration (for debug)
grunt.registerTask('logConfig', 'Output the generated configuration object', function() {
grunt.log.subhead('* Generated config file: *');
grunt.log.writeln(JSON.stringify(config, undefined, 2));
});
};