chore: analyze travis commit and check for blocked statements.

Fixes #175.

Closes #180
This commit is contained in:
DevVersion
2016-03-17 18:17:58 +01:00
committed by Jeremy Elbourn
parent 6db351140b
commit 165ccece47
2 changed files with 31 additions and 0 deletions
+1
View File
@@ -63,6 +63,7 @@ before_script:
- "sh -e /etc/init.d/xvfb start"
- mkdir -p $LOGS_DIR
- npm run tslint
- "node ./scripts/ci/analyze-commits.js"
script:
+30
View File
@@ -0,0 +1,30 @@
'use strict';
/*
* This script analyzes the current commits of the CI.
* It will search for blocked statements, which have been added in the commits and fail if present.
*/
var child_process = require('child_process');
var blocked_statements = [
'ddescribe',
'fdescribe',
'iit',
'fit',
'xdescribe',
'xit',
'debugger;'
];
var blockedRegex = new RegExp('\\+.*(' + blocked_statements.join('|') + ').*$', 'mg');
var diff = child_process.execSync('git diff --unified=0 HEAD~1 ./src ./e2e').toString();
var isInvalid = blockedRegex.test(diff);
if (isInvalid) {
console.warn('Warning: You are using a statement in your commit, which is not allowed.\n' +
'Blocked Statements are: ' + blocked_statements.join(', ') + '\n' +
'Please remove them, and the CI will continue.');
process.exit(1);
} else {
console.log('Info: The commits have been analyzed and are valid!');
}