This repository has been archived by the owner on Jan 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
67 lines (48 loc) · 1.57 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
'use strict'
var GruntInitializer = function( o ) {
this.grunt = o.grunt
this.initiliazeConfig()
this.defineGruntGlobals()
this.initializeGrunt()
this.loadGruntDependencies()
this.loadTasks()
}
GruntInitializer.prototype = {
initiliazeConfig: function() {
this.moduleConfig = this.grunt.file.readJSON( './config.json' )
this.packageConfig = this.grunt.file.readJSON( './package.json' )
try {
this.credentialsConfig = this.grunt.file.readJSON( './.credentials.json' )
} catch ( e ) {
this.credentialsConfig = this.credentialsConfig || {}
}
this.config = this.moduleConfig
this.config.credentials = this.credentialsConfig
for ( var i in this.packageConfig ) // extend module config with package.json
if ( this.packageConfig.hasOwnProperty( i ) )
if ( !this.config[ i ] )
this.config[ i ] = this.packageConfig[ i ]
},
defineGruntGlobals: function() {
this.grunt.mangroveConfig = this
},
get: function( path ){
return this.grunt.config.get( 'config.' + path )
},
loadGruntDependencies: function() {
require( 'matchdep' ).filterDev( 'grunt-*' ).forEach( this.grunt.loadNpmTasks )
},
initializeGrunt: function() {
this.grunt.initConfig( {
config: this.config
} )
},
loadTasks: function() {
this.grunt.loadTasks( 'tasks' )
}
}
module.exports = function( grunt ) {
new GruntInitializer( {
grunt: grunt
} )
}