-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.js
78 lines (52 loc) · 2.43 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
/* -------------------------------------------------------------------------------------
GRUNT: Boilerplate
http://github.com/chrometoasters/ct-grunt-boilerplate
http://www.thomasboyt.com/2013/09/01/maintainable-grunt.html
Prerequesites:
(sudo) npm install glob
-------------------------------------------------------------------------------------*/
// JSHINT:
/*globals module:true, require:true */
module.exports = function(grunt) {
"use strict"; // JSHINT - Use ECMAScript 5 Strict Mode
/* -------------------------------------------------------------------------------------
LOAD PLUGINS AND TASKS
-------------------------------------------------------------------------------------*/
// https://github.com/sindresorhus/load-grunt-tasks
// This module will read the dependencies/devDependencies/peerDependencies
// in your package.json and load grunt tasks
// that match the `grunt-*` pattern
// Equivalent to require('load-grunt-tasks')(grunt, {pattern: 'grunt-*'});
require('load-grunt-tasks')(grunt);
grunt.loadTasks('grunt-tasks');
var path = require('path'); // DS
function loadConfig(path) {
var glob = require('glob');
var object = {};
var key;
glob.sync('*', {cwd: path}).forEach(function(option) {
key = option.replace(/\.js$/,'');
object[key] = require(path + option);
});
return object;
}
/* -------------------------------------------------------------------------------------
IMPORT CONFIGURATION FILES
-------------------------------------------------------------------------------------*/
var config = {
pkg: grunt.file.readJSON('package.json'),
project_root: path.resolve(),
env: process.env
};
// paths are usually relative to Gruntfile.js, which may be in a theme folder rather than the document root
// so path_from_document_root is used for PHP and CSS/JS includes
config.pkg.project.path_from_document_root = config.project_root.split( config.pkg.project.document_root + '/' )[1];
// if there is a path, then we are not in the root, and we are in a sub folder
//if ( config.pkg.project.path_from_document_root.length > 0 ) {
// add a forward slash to navigate into the subfolder
// config.pkg.project.path_from_document_root += '/';
//}
//grunt.log.write( 'test: ' + config.pkg.project.path_from_document_root );
grunt.util._.extend(config, loadConfig('./grunt-tasks/options/'));
grunt.initConfig(config);
};