1
+ #!/usr/bin/env node
2
+
1
3
'use strict' ;
2
4
/*
3
5
* This script analyzes the current commits of the CI.
@@ -27,7 +29,8 @@ const blocked_statements = [
27
29
'\\bfit\\(' ,
28
30
'\\bxdescribe\\(' ,
29
31
'\\bxit\\(' ,
30
- '\\bdebugger;'
32
+ '\\bdebugger;' ,
33
+ 'from \\\'rxjs/Rx\\\'' ,
31
34
] ;
32
35
33
36
const blockedRegex = new RegExp ( blocked_statements . join ( '|' ) , 'g' ) ;
@@ -62,10 +65,10 @@ function getCommitRange() {
62
65
*/
63
66
function findChangedFiles ( ) {
64
67
return getCommitRange ( )
65
- . then ( function ( range ) {
68
+ . then ( range => {
66
69
return exec ( `git diff --name-status ${ range } ./src ./e2e` ) ;
67
70
} )
68
- . then ( function ( rawDiff ) {
71
+ . then ( rawDiff => {
69
72
// Ignore deleted files.
70
73
return rawDiff . split ( '\n' )
71
74
. filter ( function ( line ) {
@@ -85,13 +88,13 @@ function findChangedFiles() {
85
88
86
89
// Find all files, check for errors, and output every errors found.
87
90
findChangedFiles ( )
88
- . then ( function ( fileList ) {
91
+ . then ( fileList => {
89
92
// Only match .js or .ts, and remove .d.ts files.
90
93
return fileList . filter ( function ( name ) {
91
94
return name . match ( / \. [ j t ] s $ / ) && ! name . match ( / \. d \. t s $ / ) ;
92
95
} ) ;
93
96
} )
94
- . then ( function ( fileList ) {
97
+ . then ( fileList => {
95
98
// Read every file and return a Promise that will contain an array of
96
99
// Object of the form { fileName, content }.
97
100
return Promise . all ( fileList . map ( function ( fileName ) {
@@ -101,10 +104,10 @@ findChangedFiles()
101
104
} ;
102
105
} ) ) ;
103
106
} )
104
- . then ( function ( diffList ) {
107
+ . then ( diffList => {
105
108
// Reduce the diffList to an array of errors. The array will be empty if no errors
106
109
// were found.
107
- return diffList . reduce ( function ( errors , diffEntry ) {
110
+ return diffList . reduce ( ( errors , diffEntry ) => {
108
111
let fileName = diffEntry . fileName ;
109
112
let content = diffEntry . content . split ( '\n' ) ;
110
113
let ln = 0 ;
@@ -126,17 +129,17 @@ findChangedFiles()
126
129
return errors ;
127
130
} , [ ] ) ;
128
131
} )
129
- . then ( function ( errors ) {
132
+ . then ( errors => {
130
133
if ( errors . length > 0 ) {
131
134
console . error ( 'Error: You are using a statement in your commit, which is not allowed.' ) ;
132
- errors . forEach ( function ( entry ) {
135
+ errors . forEach ( entry => {
133
136
console . error ( ` ${ entry . fileName } @${ entry . lineNumber } , Statement: ${ entry . statement } .\n` ) ;
134
137
} ) ;
135
138
136
139
process . exit ( 1 ) ;
137
140
}
138
141
} )
139
- . catch ( function ( err ) {
142
+ . catch ( err => {
140
143
// An error occured in this script. Output the error and the stack.
141
144
console . error ( 'An error occured during execution:' ) ;
142
145
console . error ( err ) ;
0 commit comments