Skip to content

Commit

Permalink
chore: block import of entire rxjs library (angular#625)
Browse files Browse the repository at this point in the history
  • Loading branch information
jelbourn committed Jun 3, 2016
1 parent f7f0b4a commit 7419a12
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions scripts/ci/forbidden-identifiers.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

'use strict';
/*
* This script analyzes the current commits of the CI.
Expand Down Expand Up @@ -27,7 +29,8 @@ const blocked_statements = [
'\\bfit\\(',
'\\bxdescribe\\(',
'\\bxit\\(',
'\\bdebugger;'
'\\bdebugger;',
'from \\\'rxjs/Rx\\\'',
];

const blockedRegex = new RegExp(blocked_statements.join('|'), 'g');
Expand Down Expand Up @@ -62,10 +65,10 @@ function getCommitRange() {
*/
function findChangedFiles() {
return getCommitRange()
.then(function(range) {
.then(range => {
return exec(`git diff --name-status ${range} ./src ./e2e`);
})
.then(function(rawDiff) {
.then(rawDiff => {
// Ignore deleted files.
return rawDiff.split('\n')
.filter(function(line) {
Expand All @@ -85,13 +88,13 @@ function findChangedFiles() {

// Find all files, check for errors, and output every errors found.
findChangedFiles()
.then(function(fileList) {
.then(fileList => {
// Only match .js or .ts, and remove .d.ts files.
return fileList.filter(function(name) {
return name.match(/\.[jt]s$/) && !name.match(/\.d\.ts$/);
});
})
.then(function(fileList) {
.then(fileList => {
// Read every file and return a Promise that will contain an array of
// Object of the form { fileName, content }.
return Promise.all(fileList.map(function(fileName) {
Expand All @@ -101,10 +104,10 @@ findChangedFiles()
};
}));
})
.then(function(diffList) {
.then(diffList => {
// Reduce the diffList to an array of errors. The array will be empty if no errors
// were found.
return diffList.reduce(function(errors, diffEntry) {
return diffList.reduce((errors, diffEntry) => {
let fileName = diffEntry.fileName;
let content = diffEntry.content.split('\n');
let ln = 0;
Expand All @@ -126,17 +129,17 @@ findChangedFiles()
return errors;
}, []);
})
.then(function(errors) {
.then(errors => {
if (errors.length > 0) {
console.error('Error: You are using a statement in your commit, which is not allowed.');
errors.forEach(function(entry) {
errors.forEach(entry => {
console.error(` ${entry.fileName}@${entry.lineNumber}, Statement: ${entry.statement}.\n`);
});

process.exit(1);
}
})
.catch(function(err) {
.catch(err => {
// An error occured in this script. Output the error and the stack.
console.error('An error occured during execution:');
console.error(err);
Expand Down

0 comments on commit 7419a12

Please sign in to comment.