Skip to content

Commit bb35354

Browse files
committed
tasks: try 'madge' to check for circular dependencies
1 parent c837359 commit bb35354

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"karma-coverage": "^1.0.0",
105105
"karma-firefox-launcher": "^1.0.0",
106106
"karma-jasmine": "^1.0.2",
107+
"madge": "^0.6.0",
107108
"node-sass": "^3.4.1",
108109
"npm-link-check": "^1.1.0",
109110
"open": "0.0.5",

tasks/test_syntax.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var fs = require('fs');
33

44
var falafel = require('falafel');
55
var glob = require('glob');
6+
var madge = require('madge');
67

78
var constants = require('./util/constants');
89
var srcGlob = path.join(constants.pathToSrc, '**/*.js');
@@ -14,6 +15,7 @@ var bundleTestGlob = path.join(constants.pathToJasmineBundleTests, '**/*.js');
1415
assertJasmineSuites();
1516
assertHeaders();
1617
assertFileNames();
18+
assertCircularDeps();
1719

1820

1921
// check for for focus and exclude jasmine blocks
@@ -94,6 +96,23 @@ function assertFileNames() {
9496

9597
}
9698

99+
// check circular dependencies
100+
function assertCircularDeps() {
101+
var dependencyObject = madge(constants.pathToSrc);
102+
var circularDeps = dependencyObject.circular().getArray();
103+
var logs = [];
104+
105+
// as of 2016/08/19
106+
// see https://github.com/plotly/plotly.js/milestone/9
107+
// for more details
108+
var MAX_ALLOWED_CIRCULAR_DEPS = 31;
109+
110+
if(circularDeps.length > MAX_ALLOWED_CIRCULAR_DEPS) {
111+
logs.push('some new circular dependencies were added to src/');
112+
}
113+
114+
log('circular dependencies', logs);
115+
}
97116
function combineGlobs(arr) {
98117
return '{' + arr.join(',') + '}';
99118
}

0 commit comments

Comments
 (0)