diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2013-01-23 17:42:28 -0500 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2013-01-25 10:03:53 -0500 |
commit | ac93559eb9f18fcaec95dfdc97358b1b85bfe234 (patch) | |
tree | 00547721432a2ff49cf57adfebf1173a083f3cb9 /Gruntfile.js | |
parent | 079ee502d6ef150dac0fe8143d55acf93c5a51db (diff) | |
download | jquery-ac93559eb9f18fcaec95dfdc97358b1b85bfe234.tar.gz jquery-ac93559eb9f18fcaec95dfdc97358b1b85bfe234.zip |
Fix #13274: Wrap sourceMap directive in multiline comments. Close gh-1143.
Diffstat (limited to 'Gruntfile.js')
-rw-r--r-- | Gruntfile.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Gruntfile.js b/Gruntfile.js index 5b45547ff..5ad39bf02 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -409,7 +409,7 @@ module.exports = function( grunt ) { nonascii = false; distpaths.forEach(function( filename ) { - var i, c, + var i, c, map, text = fs.readFileSync( filename, "utf8" ); // Ensure files use only \n for line endings, not \r\n @@ -438,7 +438,18 @@ module.exports = function( grunt ) { text = text.replace( /"dist\//g, "\"" ); fs.writeFileSync( filename, text, "utf-8" ); } else if ( /\.min\.js$/.test( filename ) ) { - text = text.replace( /sourceMappingURL=dist\//, "sourceMappingURL=" ); + // Wrap sourceMap directive in multiline comments (#13274) + text = text.replace( /\n?(\/\/@\s*sourceMappingURL=)(.*)/, + function( _, directive, path ) { + map = "\n" + directive + path.replace( /^dist\//, "" ); + return ""; + }); + if ( map ) { + text = text.replace( /(^\/\*[\w\W]*?)\s*\*\/|$/, + function( _, comment ) { + return ( comment || "\n/*" ) + map + "\n*/"; + }); + } fs.writeFileSync( filename, text, "utf-8" ); } |