forked from godaddy-wordpress/wc-plugin-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
86 lines (67 loc) · 1.69 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
84
85
86
/* jshint node:true */
module.exports = function( grunt ) {
'use strict';
// load all grunt tasks matching the `grunt-*` pattern
require( 'load-grunt-tasks' )( grunt );
// Show elapsed time
require( 'time-grunt' )( grunt );
var _ = require( 'underscore' );
var path = require( 'path' );
var gruntConfig = {};
// options
gruntConfig.options = {};
gruntConfig.pkg = grunt.file.readJSON( 'package.json' ),
// Set folder templates
gruntConfig.dirs = {
lang: 'woocommerce/i18n/languages',
general: {
css: 'woocommerce/assets/css',
js: 'woocommerce/assets/js'
},
gateway : {
css: 'woocommerce/payment-gateway/assets/css',
js: 'woocommerce/payment-gateway/assets/js'
}
};
function loadConfig( filepath ) {
var object = {};
var key;
filepath = path.normalize( path.resolve( process.cwd(), filepath ) + '/' )
var files = grunt.file.glob.sync( '*', { cwd: filepath } );
files.forEach( function( option ) {
key = option.replace(/\.js$/,'');
object = _.extend( object, require( filepath + option )( grunt ) );
});
return object;
};
// load task configs
gruntConfig = _.extend( gruntConfig, loadConfig( './grunt/configs/' ) );
// Init Grunt
grunt.initConfig( gruntConfig );
// Load custom tasks
grunt.loadTasks( 'grunt/tasks/' );
// Register update_translations task
grunt.registerTask( 'update_translations', [
'makepot',
'shell:tx_push',
'shell:tx_pull',
'potomo'
] );
// Register build task
grunt.registerTask( 'build', [
'coffee',
'uglify',
'sass',
'update_translations',
'clean'
] );
// Register default task
grunt.registerTask( 'default', [
'coffee',
'uglify',
'sass',
'makepot',
'shell:tx_push',
'clean'
] );
};