Skip to content

Commit

Permalink
Gruntfile.js: Escaped curly braces used in some regular expressions
Browse files Browse the repository at this point in the history
Fixes #527
Closes #529
  • Loading branch information
Arkni authored and rxaviers committed Oct 10, 2015
1 parent 2dd6b6f commit 757e782
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ module.exports = function( grunt ) {

// Remove browserify wrappers.
.replace( /^\(function\(f\){if\(typeof exports==="object"&&type.*/, "" )
.replace( /},{}\]},{},\[1\]\)\(1\)[\s\S]*?$/, "" )
.replace( /\},\{\}\]\},\{\},\[1\]\)\(1\)[\s\S]*?$/, "" )

// Remove browserify exports.
.replace( /Object.defineProperty\(exports[\s\S]*?\n}\);/, "" )
Expand All @@ -156,10 +156,10 @@ module.exports = function( grunt ) {
.replace( "this.tests.add(type, cat, examples);", "" )

// Remove load method.
.replace( /load: {[\s\S]*?\n }/, "" )
.replace( /load: \{[\s\S]*?\n \}/, "" )

// Replace its wrapper into var assignment.
.replace( /\(function \(global\) {/, [
.replace( /\(function \(global\) \{/, [
"var MakePlural;",
"/* jshint ignore:start */",
"MakePlural = (function() {"
Expand Down Expand Up @@ -187,10 +187,10 @@ module.exports = function( grunt ) {
return contents

// Remove browserify wrappers.
.replace( /^\(function\(f\){if\(typeof exports==="object"&&type.*/, "" )
.replace( /^\(function\(f\)\{if\(typeof exports==="object"&&type.*/, "" )
.replace( "},{}],2:[function(require,module,exports){", "" )
.replace( /},{"\.\/messageformat-parser":1,"make-plural\/plural.*/, "" )
.replace( /},{}\]},{},\[2\]\)\(2\)[\s\S]*?$/, "" )
.replace( /\},\{"\.\/messageformat-parser":1,"make-plural\/plural.*/, "" )
.replace( /\},\{\}\]\},\{\},\[2\]\)\(2\)[\s\S]*?$/, "" )

// Set `MessageFormat.plurals` and remove `make-plural/plurals`
// completely. This is populated by Globalize on demand.
Expand All @@ -205,17 +205,17 @@ module.exports = function( grunt ) {
"MessageFormat._parse = require('./messageformat-parser').parse;",
""
)
.replace( /module\.exports = \(function\(\) {([\s\S]*?)\n}\)\(\);/, [
.replace( /module\.exports = \(function\(\) \{([\s\S]*?)\n\}\)\(\);/, [
"MessageFormat._parse = (function() {",
"$1",
"}()).parse;"
].join( "\n" ) )

// Remove unused code.
.replace( /if \(!pluralFunc\) {\n[\s\S]*?\n }/, "" )
.replace( /if \(!locale\) {\n[\s\S]*? }\n/, "this.lc = [locale];" )
.replace( /(MessageFormat\.formatters) = {[\s\S]*?\n};/, "$1 = {};" )
.replace( /MessageFormat\.prototype\.setIntlSupport[\s\S]*?\n};/, "" )
.replace( /if \(!pluralFunc\) \{\n[\s\S]*?\n \}/, "" )
.replace( /if \(!locale\) \{\n[\s\S]*? \}\n/, "this.lc = [locale];" )
.replace( /(MessageFormat\.formatters) = \{[\s\S]*?\n\};/, "$1 = {};" )
.replace( /MessageFormat\.prototype\.setIntlSupport[\s\S]*?\n\};/, "" )

// Wrap everything into a var assignment.
.replace( "module.exports = MessageFormat;", "" )
Expand Down Expand Up @@ -248,7 +248,7 @@ module.exports = function( grunt ) {
// 1, and 2: Remove define() wrap.
// 3: Remove empty define()'s.
contents = contents
.replace( /define\([^{]*?{/, "" ) /* 1 */
.replace( /define\([^{]*?\{/, "" ) /* 1 */
.replace( rdefineEnd, "" ) /* 2 */
.replace( /define\(\[[^\]]+\]\)[\W\n]+$/, "" ); /* 3 */

Expand Down

0 comments on commit 757e782

Please sign in to comment.