@@ -6,20 +6,20 @@ var glob = require('glob');
6
6
7
7
var constants = require ( '../tasks/util/constants' ) ;
8
8
9
- var BLACK_LIST = [ 'fdescribe' , 'fit' , 'xdescribe' , 'xit' ] ;
10
- var logs = [ ] ;
9
+ // check for for focus and exclude jasmine blocks
11
10
11
+ var BLACK_LIST = [ 'fdescribe' , 'fit' , 'xdescribe' , 'xit' ] ;
12
12
var testGlob = path . join ( constants . pathToJasmineTests , '**/*.js' ) ;
13
13
var bundleTestGlob = path . join ( constants . pathToJasmineBundleTests , '**/*.js' ) ;
14
14
15
-
15
+ var logsJasmine = [ ] ;
16
16
glob ( '{' + testGlob + ',' + bundleTestGlob + '}' , function ( err , files ) {
17
17
files . forEach ( function ( file ) {
18
18
var code = fs . readFileSync ( file , 'utf-8' ) ;
19
19
20
20
falafel ( code , { locations : true } , function ( node ) {
21
21
if ( node . type === 'Identifier' && BLACK_LIST . indexOf ( node . name ) !== - 1 ) {
22
- logs . push ( [
22
+ logsJasmine . push ( [
23
23
path . basename ( file ) ,
24
24
'[line ' + node . loc . start . line + '] :' ,
25
25
'contains either a *fdescribe*, *fit*,' ,
@@ -30,5 +30,40 @@ glob('{' + testGlob + ',' + bundleTestGlob + '}', function(err, files) {
30
30
31
31
} ) ;
32
32
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
+ }
34
69
} ) ;
0 commit comments