-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Gruntfile.js
113 lines (101 loc) · 2.89 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
102
103
104
105
106
107
108
109
110
111
112
113
module.exports = function( grunt ) {
'use strict';
const sass = require( 'sass' );
// Project configuration
grunt.initConfig( {
pkg: grunt.file.readJSON( 'package.json' ),
addtextdomain: {
options: {
textdomain: 'a-z-listing',
},
update_all_domains: {
options: {
updateDomains: true
},
src: [ '*.php', '**/*.php', '!\.git/**/*', '!bin/**/*', '!node_modules/**/*', '!tests/**/*', '!build/**/*', '!vendor/**/*' ]
}
},
wp_readme_to_markdown: {
your_target: {
files: {
'README.md': 'readme.txt'
},
options: {
screenshot_url: '.wordpress-org/{screenshot}.png',
pre_convert: function( readme ) {
readme = readme.replace( new RegExp('^`$[\n\r]+([^`]*)[\n\r]+^`$','gm'), function( codeblock, codeblockContents ) {
const blockStartEnd = '```';
let lines = codeblockContents.split('\n');
if ( String( lines[0] ).startsWith('<?php') ) {
return `${blockStartEnd}php\n${lines.join('\n')}\n${blockStartEnd}`;
}
});
return readme;
},
post_convert: function( readme ) {
readme = readme.replace( /^## Description ##$/, function( title ) {
return `${title}\n\n[![Build Status](https://travis-ci.org/bowlhat/wp-a-z-listing.svg?branch=master)](https://travis-ci.org/bowlhat/wp-a-z-listing)\n\n`;
});
readme = readme.replace( /^\*\*([^*\s][^*]*)\*\*$/gm, function( a, b ) {
return `#### ${b} ####`;
});
readme = readme.replace( /^\*([^*\s][^*]*)\*$/gm, function( a, b ) {
return `##### ${b} #####`;
});
return readme;
}
}
},
},
makepot: {
target: {
options: {
domainPath: '/languages',
exclude: [ '\.git/*', 'bin/*', 'node_modules/*', 'tests/*', 'vendor/*' ],
mainFile: 'a-z-listing.php',
potFilename: 'a-z-listing.pot',
potHeaders: {
poedit: true,
'x-poedit-keywordslist': true
},
type: 'wp-plugin',
updateTimestamp: true
}
}
},
// babel: {
// options: {
// sourceMap: true,
// plugins: [['transform-react-jsx', {"pragma": "wp.element.createElement"}]],
// presets: ['env', 'react']
// },
// jsx: {
// files: [{
// expand: true,
// src: ['**/*.jsx'],
// ext: '.js'
// }]
// }
// },
sass: {
options: {
sourceMap: true,
implementation: sass
},
dist: {
files: {
'css/a-z-listing-default.css': 'css/a-z-listing-default.scss',
'css/a-z-listing-customize.css': 'css/a-z-listing-customize.scss'
}
}
},
} );
grunt.loadNpmTasks( 'grunt-wp-i18n' );
grunt.loadNpmTasks( 'grunt-wp-readme-to-markdown' );
grunt.loadNpmTasks( 'grunt-sass' );
grunt.registerTask( 'default', ['build'] );
grunt.registerTask( 'build', [ 'i18n','readme','sass' ] );
grunt.registerTask( 'i18n', ['addtextdomain', 'makepot'] );
grunt.registerTask( 'readme', ['wp_readme_to_markdown'] );
grunt.util.linefeed = '\n';
};