-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathGruntfile.js
More file actions
60 lines (44 loc) · 1.34 KB
/
Gruntfile.js
File metadata and controls
60 lines (44 loc) · 1.34 KB
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
/* global module, require */
module.exports = function( grunt ) {
'use strict';
var pkg = grunt.file.readJSON( 'package.json' );
grunt.initConfig( {
pkg: pkg,
devUpdate: {
check: {},
update: {
options: {
updateType: 'force'
}
}
},
wp_readme_to_markdown: {
options: {
post_convert: function( readme ) {
var matches = readme.match( /\*\*Tags:\*\*(.*)\r?\n/ ),
tags = matches[1].trim().split( ', ' ),
section = matches[0];
for ( var i = 0; i < tags.length; i++ ) {
section = section.replace( tags[i], '[' + tags[i] + '](https://wordpress.org/plugins/tags/' + tags[i] + '/)' );
}
// Tag links
readme = readme.replace( matches[0], section );
// Badges
readme = readme.replace( '## Description ##', grunt.template.process( pkg.badges.join( ' ' ) ) + " \r\n\r\n## Description ##" );
return readme;
},
screenshot_url: 'https://ps.w.org/{plugin}/assets/{screenshot}.png'
},
main: {
files: {
'readme.md': 'readme.txt'
}
}
}
} );
require( 'matchdep' ).filterDev( 'grunt-*' ).forEach( grunt.loadNpmTasks );
grunt.registerTask( 'dev-check', [ 'devUpdate:check' ] );
grunt.registerTask( 'dev-update', [ 'devUpdate:update' ] );
grunt.registerTask( 'readme', [ 'wp_readme_to_markdown' ] );
grunt.util.linefeed = '\n';
};