@@ -4,6 +4,7 @@ var fs = require('fs');
44var falafel = require ( 'falafel' ) ;
55var glob = require ( 'glob' ) ;
66var madge = require ( 'madge' ) ;
7+ var readLastLines = require ( 'read-last-lines' ) ;
78
89var constants = require ( './util/constants' ) ;
910var srcGlob = path . join ( constants . pathToSrc , '**/*.js' ) ;
@@ -17,6 +18,7 @@ var EXIT_CODE = 0;
1718assertJasmineSuites ( ) ;
1819assertSrcContents ( ) ;
1920assertFileNames ( ) ;
21+ assertTrailingNewLine ( ) ;
2022assertCircularDeps ( ) ;
2123
2224
@@ -125,7 +127,39 @@ function assertFileNames() {
125127
126128 log ( 'lower case only file names' , logs ) ;
127129 } ) ;
130+ }
131+
132+ // check that all files have a trailing new line character
133+ function assertTrailingNewLine ( ) {
134+ var pattern = combineGlobs ( [
135+ path . join ( constants . pathToSrc , '**/*.glsl' ) ,
136+ path . join ( constants . pathToRoot , 'test' , 'image' , 'mocks' , '*' )
137+ ] ) ;
138+
139+ var regex = / \r ? \n $ / ;
140+ var promises = [ ] ;
141+ var logs = [ ] ;
142+
143+ glob ( pattern , function ( err , files ) {
144+ files . forEach ( function ( file ) {
145+ var promise = readLastLines . read ( file , 1 ) ;
128146
147+ promises . push ( promise ) ;
148+
149+ promise . then ( function ( lines ) {
150+ if ( ! regex . test ( lines ) ) {
151+ logs . push ( [
152+ file , ':' ,
153+ 'does not have a trailing new line character'
154+ ] . join ( ' ' ) ) ;
155+ }
156+ } ) ;
157+ } ) ;
158+
159+ Promise . all ( promises ) . then ( function ( ) {
160+ log ( 'trailing new line character' , logs ) ;
161+ } ) ;
162+ } ) ;
129163}
130164
131165// check circular dependencies
0 commit comments