forked from ellatrix/wp-front-end-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
executable file
·101 lines (97 loc) · 1.96 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
module.exports = function( grunt ) {
var SOURCE_DIR = 'src/';
var BUILD_DIR = 'build/';
var SVN = 'https://plugins.svn.wordpress.org';
require( 'matchdep' ).filterDev( ['grunt-*'] ).forEach( grunt.loadNpmTasks );
grunt.initConfig( {
pkg: grunt.file.readJSON( 'package.json' ),
getContributors: function( pkg ) {
return [ pkg.author ].concat( pkg.contributors ).map( function( person ) {
return person.wp.username;
} ).join( ', ' );
},
clean: {
all: [ BUILD_DIR ],
svn: [ BUILD_DIR + '*', '!' + BUILD_DIR + '.svn' ]
},
copy: {
all: {
expand: true,
cwd: SOURCE_DIR,
src: '**',
dest: BUILD_DIR
},
templates: {
options: {
process: grunt.template.process
},
expand: true,
cwd: SOURCE_DIR,
src: [
'plugin.php',
'readme.txt'
],
dest: BUILD_DIR
},
pkg: {
src: 'package.json',
dest: BUILD_DIR
}
},
jshint: {
options: grunt.file.readJSON( '.jshintrc' ),
all: {
expand: true,
cwd: SOURCE_DIR,
src: [
'js/*.js',
'!js/modal.js'
]
},
grunt: {
options: {
node: true
},
src: [
'Gruntfile.js'
]
}
},
jsvalidate:{
options: {
verbose: false
},
all: {
src: BUILD_DIR + 'js/*.js'
}
},
svn: {
checkout: {
cmd: 'checkout ' + SVN + '/<%= pkg.name %>/trunk ' + BUILD_DIR
},
tag: {
cmd: 'copy ' + SVN + '/<%= pkg.name %>/trunk ' + SVN + '/<%= pkg.name %>/tags/<%= pkg.version %> -m "<%= pkg.version %>"'
}
},
uglify: {
all: {
expand: true,
cwd: SOURCE_DIR,
dest: BUILD_DIR,
ext: '.min.js',
src: [ 'js/*.js' ]
}
}
} );
grunt.registerMultiTask( 'svn', function() {
grunt.util.spawn( {
cmd: 'svn',
args: this.data.cmd.split( ' ' ),
opts: {
stdio: 'inherit'
}
}, this.async() );
} );
grunt.registerTask( 'default', [ 'jshint' ] );
grunt.registerTask( 'build', [ 'clean:all', 'svn:checkout', 'clean:svn', 'copy', 'uglify', 'jsvalidate' ] );
};