Commit b45c775c authored by Dave Methvin's avatar Dave Methvin

Fix #12471. Use consistent line endings in jquery.js

parent a95f3574
...@@ -189,8 +189,8 @@ module.exports = function( grunt ) { ...@@ -189,8 +189,8 @@ module.exports = function( grunt ) {
grunt.verbose.write("Injected sizzle-jquery.js into sizzle.js"); grunt.verbose.write("Injected sizzle-jquery.js into sizzle.js");
// Write concatenated source to file // Write concatenated source to file, and ensure newline-only termination
grunt.file.write( name, compiled ); grunt.file.write( name, compiled.replace( /\x0d\x0a/g, "\x0a" ) );
// Fail task if errors were logged. // Fail task if errors were logged.
if ( this.errorCount ) { if ( this.errorCount ) {
...@@ -409,8 +409,16 @@ module.exports = function( grunt ) { ...@@ -409,8 +409,16 @@ module.exports = function( grunt ) {
nonascii = false; nonascii = false;
distpaths.forEach(function( filename ) { distpaths.forEach(function( filename ) {
var text = fs.readFileSync( filename, "utf8" ), var i, c,
i, c; text = fs.readFileSync( filename, "utf8" );
// Ensure files use only \n for line endings, not \r\n
if ( /\x0d\x0a/.test( text ) ) {
grunt.log.writeln( filename + ": Incorrect line endings (\\r\\n)" );
nonascii = true;
}
// Ensure only ASCII chars so script tags don't need a charset attribute
if ( text.length !== Buffer.byteLength( text, "utf8" ) ) { if ( text.length !== Buffer.byteLength( text, "utf8" ) ) {
grunt.log.writeln( filename + ": Non-ASCII characters detected:" ); grunt.log.writeln( filename + ": Non-ASCII characters detected:" );
for ( i = 0; i < text.length; i++ ) { for ( i = 0; i < text.length; i++ ) {
...@@ -418,10 +426,10 @@ module.exports = function( grunt ) { ...@@ -418,10 +426,10 @@ module.exports = function( grunt ) {
if ( c > 127 ) { if ( c > 127 ) {
grunt.log.writeln( "- position " + i + ": " + c ); grunt.log.writeln( "- position " + i + ": " + c );
grunt.log.writeln( "-- " + text.substring( i - 20, i + 20 ) ); grunt.log.writeln( "-- " + text.substring( i - 20, i + 20 ) );
nonascii = true;
break; break;
} }
} }
nonascii = true;
} }
// Modify map so that it points to files in the same folder; // Modify map so that it points to files in the same folder;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment