|
| 1 | +/* global module, require */ |
| 2 | + |
1 | 3 | module.exports = function( grunt ) { |
2 | 4 |
|
3 | 5 | 'use strict'; |
4 | | - // Project configuration |
| 6 | + |
| 7 | + var pkg = grunt.file.readJSON( 'package.json' ); |
| 8 | + |
5 | 9 | grunt.initConfig( { |
6 | 10 |
|
7 | | - pkg: grunt.file.readJSON( 'package.json' ), |
| 11 | + pkg: pkg, |
8 | 12 |
|
9 | | - wp_readme_to_markdown: { |
10 | | - options: { |
11 | | - screenshot_url: 'https://s.w.org/plugins/{plugin}/{screenshot}.png', |
12 | | - }, |
13 | | - your_target: { |
14 | | - files: { |
15 | | - 'README.md': 'readme.txt' |
| 13 | + devUpdate: { |
| 14 | + check: {}, |
| 15 | + update: { |
| 16 | + options: { |
| 17 | + updateType: 'force' |
16 | 18 | } |
17 | | - }, |
| 19 | + } |
18 | 20 | }, |
19 | 21 |
|
20 | 22 | phpcs: { |
21 | | - plugin: { |
22 | | - src: './' |
23 | | - }, |
24 | 23 | options: { |
25 | | - bin: "vendor/bin/phpcs --extensions=php --ignore=\"*/vendor/*,*/lib/*,*/node_modules/*\"", |
26 | | - standard: "phpcs.ruleset.xml" |
| 24 | + bin: 'vendor/bin/phpcs --extensions=php --ignore="*/vendor/*,*/lib/*,*/node_modules/*"', |
| 25 | + standard: 'phpcs.ruleset.xml' |
| 26 | + }, |
| 27 | + main: { |
| 28 | + src: '*.php' |
27 | 29 | } |
28 | 30 | }, |
29 | 31 |
|
| 32 | + wp_readme_to_markdown: { |
| 33 | + options: { |
| 34 | + post_convert: function( readme ) { |
| 35 | + var matches = readme.match( /\*\*Tags:\*\*(.*)\r?\n/ ), |
| 36 | + tags = matches[1].trim().split( ', ' ), |
| 37 | + section = matches[0]; |
| 38 | + |
| 39 | + for ( var i = 0; i < tags.length; i++ ) { |
| 40 | + section = section.replace( tags[i], '[' + tags[i] + '](https://wordpress.org/plugins/tags/' + tags[i] + '/)' ); |
| 41 | + } |
| 42 | + |
| 43 | + // Tag links |
| 44 | + readme = readme.replace( matches[0], section ); |
| 45 | + |
| 46 | + // Badges |
| 47 | + readme = readme.replace( '## Description ##', grunt.template.process( pkg.badges.join( ' ' ) ) + " \r\n\r\n## Description ##" ); |
| 48 | + |
| 49 | + return readme; |
| 50 | + }, |
| 51 | + screenshot_url: 'https://ps.w.org/{plugin}/assets/{screenshot}.png' |
| 52 | + }, |
| 53 | + main: { |
| 54 | + files: { |
| 55 | + 'readme.md': 'readme.txt' |
| 56 | + } |
| 57 | + } |
| 58 | + } |
| 59 | + |
30 | 60 | } ); |
31 | 61 |
|
32 | | - grunt.loadNpmTasks( 'grunt-wp-readme-to-markdown' ); |
33 | | - grunt.loadNpmTasks( 'grunt-phpcs' ); |
34 | | - grunt.registerTask( 'readme', ['wp_readme_to_markdown']); |
| 62 | + require( 'matchdep' ).filterDev( 'grunt-*' ).forEach( grunt.loadNpmTasks ); |
| 63 | + |
| 64 | + grunt.registerTask( 'dev-check', [ 'devUpdate:check' ] ); |
| 65 | + grunt.registerTask( 'dev-update', [ 'devUpdate:update' ] ); |
| 66 | + grunt.registerTask( 'readme', [ 'wp_readme_to_markdown' ] ); |
35 | 67 |
|
36 | 68 | grunt.util.linefeed = '\n'; |
37 | 69 |
|
|
0 commit comments