@@ -6,20 +6,20 @@ var glob = require('glob');
66
77var constants = require ( '../tasks/util/constants' ) ;
88
9- var BLACK_LIST = [ 'fdescribe' , 'fit' , 'xdescribe' , 'xit' ] ;
10- var logs = [ ] ;
9+ // check for for focus and exclude jasmine blocks
1110
11+ var BLACK_LIST = [ 'fdescribe' , 'fit' , 'xdescribe' , 'xit' ] ;
1212var testGlob = path . join ( constants . pathToJasmineTests , '**/*.js' ) ;
1313var bundleTestGlob = path . join ( constants . pathToJasmineBundleTests , '**/*.js' ) ;
1414
15-
15+ var logsJasmine = [ ] ;
1616glob ( '{' + testGlob + ',' + bundleTestGlob + '}' , function ( err , files ) {
1717 files . forEach ( function ( file ) {
1818 var code = fs . readFileSync ( file , 'utf-8' ) ;
1919
2020 falafel ( code , { locations : true } , function ( node ) {
2121 if ( node . type === 'Identifier' && BLACK_LIST . indexOf ( node . name ) !== - 1 ) {
22- logs . push ( [
22+ logsJasmine . push ( [
2323 path . basename ( file ) ,
2424 '[line ' + node . loc . start . line + '] :' ,
2525 'contains either a *fdescribe*, *fit*,' ,
@@ -30,5 +30,40 @@ glob('{' + testGlob + ',' + bundleTestGlob + '}', function(err, files) {
3030
3131 } ) ;
3232
33- if ( logs . length ) throw new Error ( '\n' + logs . join ( '\n' ) + '\n' ) ;
33+ if ( logsJasmine . length ) {
34+ throw new Error ( '\n' + logsJasmine . join ( '\n' ) + '\n' ) ;
35+ }
36+ } ) ;
37+
38+ // check for header in src and lib files
39+
40+ var licenseSrc = constants . licenseSrc ;
41+ var licenseStr = licenseSrc . substring ( 2 , licenseSrc . length - 2 ) ;
42+ var srcGlob = path . join ( constants . pathToSrc , '**/*.js' ) ;
43+ var libGlob = path . join ( constants . pathToLib , '**/*.js' ) ;
44+
45+ var logsHeader = [ ] ;
46+ glob ( '{' + srcGlob + ',' + libGlob + '}' , function ( err , files ) {
47+ files . forEach ( function ( file ) {
48+ var code = fs . readFileSync ( file , 'utf-8' ) ;
49+
50+ // parse through code string while keeping track of comments
51+ var comments = [ ] ;
52+ falafel ( code , { onComment : comments , locations : true } , function ( ) { } ) ;
53+
54+ var header = comments [ 0 ] ;
55+
56+ if ( ! header || header . loc . start . line > 1 ) {
57+ logsHeader . push ( file + ' : has no header information.' ) ;
58+ return ;
59+ }
60+
61+ if ( header . value !== licenseStr ) {
62+ logsHeader . push ( file + ' : has incorrect header information.' ) ;
63+ }
64+ } ) ;
65+
66+ if ( logsHeader . length ) {
67+ throw new Error ( '\n' + logsHeader . join ( '\n' ) + '\n' ) ;
68+ }
3469} ) ;
0 commit comments