2012-06-08 15:35:11 +00:00
|
|
|
module.exports = function( grunt ) {
|
|
|
|
|
2012-10-22 21:41:54 +00:00
|
|
|
"use strict";
|
|
|
|
|
2012-06-16 12:36:57 +00:00
|
|
|
grunt.registerTask( "clean", function() {
|
|
|
|
require( "rimraf" ).sync( "dist" );
|
2015-03-06 15:35:10 +00:00
|
|
|
} );
|
2012-06-16 12:36:57 +00:00
|
|
|
|
2013-06-14 07:01:02 +00:00
|
|
|
grunt.registerTask( "asciilint", function() {
|
|
|
|
var valid = true,
|
2015-03-06 15:35:10 +00:00
|
|
|
files = grunt.file.expand( { filter: "isFile" }, "ui/*.js" );
|
|
|
|
files.forEach( function( filename ) {
|
2013-06-14 07:01:02 +00:00
|
|
|
var i, c,
|
|
|
|
text = grunt.file.read( filename );
|
|
|
|
|
|
|
|
// Ensure files use only \n for line endings, not \r\n
|
|
|
|
if ( /\x0d\x0a/.test( text ) ) {
|
|
|
|
grunt.log.error( filename + ": Incorrect line endings (\\r\\n)" );
|
|
|
|
valid = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure only ASCII chars so script tags don't need a charset attribute
|
|
|
|
if ( text.length !== Buffer.byteLength( text, "utf8" ) ) {
|
|
|
|
grunt.log.error( filename + ": Non-ASCII characters detected:" );
|
|
|
|
for ( i = 0; i < text.length; i++ ) {
|
|
|
|
c = text.charCodeAt( i );
|
|
|
|
if ( c > 127 ) {
|
|
|
|
grunt.log.error( "- position " + i + ": " + c );
|
|
|
|
grunt.log.error( "-- " + text.substring( i - 20, i + 20 ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
valid = false;
|
|
|
|
}
|
2015-03-06 15:35:10 +00:00
|
|
|
} );
|
2013-06-14 07:01:02 +00:00
|
|
|
if ( valid ) {
|
|
|
|
grunt.log.ok( files.length + " files lint free." );
|
|
|
|
}
|
|
|
|
return valid;
|
2015-03-06 15:35:10 +00:00
|
|
|
} );
|
2013-06-14 07:01:02 +00:00
|
|
|
|
2012-09-13 13:50:43 +00:00
|
|
|
};
|