]> source.dussan.org Git - jquery.git/commitdiff
Build: Make the @CODE-replacing regex more robust
authorMichał Gołębiowski <m.goleb@gmail.com>
Sun, 4 Dec 2016 00:16:36 +0000 (01:16 +0100)
committerMichał Gołębiowski <m.goleb@gmail.com>
Mon, 5 Dec 2016 17:43:10 +0000 (18:43 +0100)
The code replacing @CODE in wrapper.js was written so that it expected
both the code and the next line to start in the first column. This commit
adjusts the regex so to get rid of that assumption and to work properly
regardless of number of lines with comments after this block.

While this is technically not necessary for our code, contributors sometimes
re-format the wrapper file in their pull requests and the error
messages they get don't tell them what's the real problem with their code.

Closes gh-3429

build/tasks/build.js

index 1579691a08989b11cecf90eb6df283d5dc153544..69916bf022041182a2ead105be52bcb20fddfb84 100644 (file)
@@ -17,7 +17,11 @@ module.exports = function( grunt ) {
                read = function( fileName ) {
                        return grunt.file.read( srcFolder + fileName );
                },
-               wrapper = read( "wrapper.js" ).split( /\/\/ \@CODE\n\/\/[^\n]+/ ),
+
+               // Catch `// @CODE` and subsequent comment lines event if they don't start
+               // in the first column.
+               wrapper = read( "wrapper.js" ).split( /[\x20\t]*\/\/ @CODE\n(?:[\x20\t]*\/\/[^\n]+\n)*/ ),
+
                config = {
                        baseUrl: "src",
                        name: "jquery",