| 1 |
"use strict"; |
| 2 |
|
| 3 |
module.exports = function( grunt ) { |
| 4 |
|
| 5 |
grunt.registerTask( "clean", function() { |
| 6 |
require( "rimraf" ).rimrafSync( "dist" ); |
| 7 |
} ); |
| 8 |
|
| 9 |
grunt.registerTask( "asciilint", function() { |
| 10 |
var valid = true, |
| 11 |
files = grunt.file.expand( { filter: "isFile" }, "ui/*.js" ); |
| 12 |
files.forEach( function( filename ) { |
| 13 |
var i, c, |
| 14 |
text = grunt.file.read( filename ); |
| 15 |
|
| 16 |
|
| 17 |
if ( /\x0d\x0a/.test( text ) ) { |
| 18 |
grunt.log.error( filename + ": Incorrect line endings (\\r\\n)" ); |
| 19 |
valid = false; |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
if ( text.length !== Buffer.byteLength( text, "utf8" ) ) { |
| 24 |
grunt.log.error( filename + ": Non-ASCII characters detected:" ); |
| 25 |
for ( i = 0; i < text.length; i++ ) { |
| 26 |
c = text.charCodeAt( i ); |
| 27 |
if ( c > 127 ) { |
| 28 |
grunt.log.error( "- position " + i + ": " + c ); |
| 29 |
grunt.log.error( "-- " + text.substring( i - 20, i + 20 ) ); |
| 30 |
break; |
| 31 |
} |
| 32 |
} |
| 33 |
valid = false; |
| 34 |
} |
| 35 |
} ); |
| 36 |
if ( valid ) { |
| 37 |
grunt.log.ok( files.length + " files lint free." ); |
| 38 |
} |
| 39 |
return valid; |
| 40 |
} ); |
| 41 |
|
| 42 |
}; |