Skip to content

Commit

Permalink
Merge pull request #5 from ismaGNU/master
Browse files Browse the repository at this point in the history
Update regex to match more options
  • Loading branch information
raulghm authored Jul 12, 2016
2 parents 9860a83 + 61d0ffc commit 1b38112
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ module.exports = function (options) {
file.contents = new Buffer(String(file.contents));

if (options.css && options.cssHandle) {
var regexCss = new RegExp("(wp_enqueue_style\\('" + options.cssHandle + "',(\\s*[^,]+,){2})\\s*[^\\)]+\\);");
var regexCss = new RegExp("(wp_(?:register|enqueue)_style\\(\\s?'" + options.cssHandle + "',(\\s*[^,]+,){2})\\s*[^,]+(,\\s*[^\\)]+)?\\);");
var hashCss = md5(options.css);
file.contents = new Buffer(String(file.contents).replace(regexCss, "$1 '" + hashCss + "');"));
file.contents = new Buffer(String(file.contents).replace(regexCss, "$1 '" + hashCss + "'$3);"));
}

if (options.js && options.jsHandle) {
var regexJs = new RegExp("(wp_register_script\\('" + options.jsHandle + "',(\\s*[^,]+,){2})\\s*[^\\)]+\\);");
var regexJs = new RegExp("(wp_(?:register|enqueue)_script\\(\\s?'" + options.jsHandle + "',(\\s*[^,]+,){2})\\s*[^,]+(,\\s*[^\\)]+)?\\);");
var hashJs = md5(options.js);
file.contents = new Buffer(String(file.contents).replace(regexJs, "$1 '" + hashJs + "');"));
file.contents = new Buffer(String(file.contents).replace(regexJs, "$1 '" + hashJs + "'$3);"));
}

this.push(file);
Expand Down

0 comments on commit 1b38112

Please sign in to comment.