Skip to content

Commit

Permalink
Fix #12471. Use consistent line endings in jquery.js
Browse files Browse the repository at this point in the history
  • Loading branch information
dmethvin committed Jan 6, 2013
1 parent c0241a4 commit b760d79
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ module.exports = function( grunt ) {

grunt.verbose.write("Injected sizzle-jquery.js into sizzle.js");

// Write concatenated source to file
grunt.file.write( name, compiled );
// Write concatenated source to file, and ensure newline-only termination
grunt.file.write( name, compiled.replace( /\x0d\x0a/g, "\x0a" ) );

// Fail task if errors were logged.
if ( this.errorCount ) {
Expand Down Expand Up @@ -409,19 +409,28 @@ module.exports = function( grunt ) {
nonascii = false;

distpaths.forEach(function( filename ) {
var text = fs.readFileSync( filename, "utf8" ),
i, c;
var 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;
return;
}

// Ensure only ASCII chars so script tags don't need a charset attribute
if ( text.length !== Buffer.byteLength( text, "utf8" ) ) {
grunt.log.writeln( filename + ": Non-ASCII characters detected:" );
for ( i = 0; i < text.length; i++ ) {
c = text.charCodeAt( i );
if ( c > 127 ) {
grunt.log.writeln( "- position " + i + ": " + c );
grunt.log.writeln( "-- " + text.substring( i - 20, i + 20 ) );
nonascii = true;
break;
}
}
nonascii = true;
}

// Modify map so that it points to files in the same folder;
Expand Down

1 comment on commit b760d79

@dmethvin
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um, that's #12741, pardon my dylsexia.

Please sign in to comment.