Skip to content

Commit 165ccec

Browse files
devversionjelbourn
authored andcommitted
chore: analyze travis commit and check for blocked statements.
Fixes #175. Closes #180
1 parent 6db3511 commit 165ccec

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ before_script:
6363
- "sh -e /etc/init.d/xvfb start"
6464
- mkdir -p $LOGS_DIR
6565
- npm run tslint
66+
- "node ./scripts/ci/analyze-commits.js"
6667

6768

6869
script:

scripts/ci/analyze-commits.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use strict';
2+
/*
3+
* This script analyzes the current commits of the CI.
4+
* It will search for blocked statements, which have been added in the commits and fail if present.
5+
*/
6+
7+
var child_process = require('child_process');
8+
var blocked_statements = [
9+
'ddescribe',
10+
'fdescribe',
11+
'iit',
12+
'fit',
13+
'xdescribe',
14+
'xit',
15+
'debugger;'
16+
];
17+
18+
var blockedRegex = new RegExp('\\+.*(' + blocked_statements.join('|') + ').*$', 'mg');
19+
20+
var diff = child_process.execSync('git diff --unified=0 HEAD~1 ./src ./e2e').toString();
21+
var isInvalid = blockedRegex.test(diff);
22+
23+
if (isInvalid) {
24+
console.warn('Warning: You are using a statement in your commit, which is not allowed.\n' +
25+
'Blocked Statements are: ' + blocked_statements.join(', ') + '\n' +
26+
'Please remove them, and the CI will continue.');
27+
process.exit(1);
28+
} else {
29+
console.log('Info: The commits have been analyzed and are valid!');
30+
}

0 commit comments

Comments
 (0)