Skip to content

Commit f2dc9cd

Browse files
test: circular deps
1 parent 08acd84 commit f2dc9cd

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

tests/circular-check.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const madge = require('madge');
2+
const path = require("path");
3+
const fs = require("fs");
4+
5+
const workingDirecotry = process.cwd();
6+
const androidApp = path.join(workingDirecotry, "platforms/android/app/src/main/assets/app/tns_modules/tns-core-modules");
7+
const iosApp = path.join(workingDirecotry, "platforms/ios/tests/app/tns_modules/tns-core-modules");
8+
9+
const iosWhiteList = ['image-source/image-source.js',
10+
'http/http.js',
11+
'http/http-request/http-request.js'];
12+
13+
const androidWhiteList = ['ui/frame/frame.js', 'ui/frame/fragment.js'];
14+
15+
const checkAppForCircualr = async (appName, whiteList) => {
16+
if (!fs.existsSync(appName)) {
17+
console.error(`${appName} doesn't exists!`);
18+
return;
19+
}
20+
21+
const result = await madge(appName);
22+
const circular = result.circular();
23+
console.info(`Check ${appName}`);
24+
console.log(`Initial check: `, circular);
25+
26+
const filteredResult = circular && circular.length > 0 && (whiteList ? circular.filter(c => whiteList.indexOf(c) >= 0) : circular);
27+
28+
if (circular && circular.length > 0 && filteredResult.length > 0) {
29+
console.log(`Found circular deps!`, filteredResult);
30+
process.exit(1);
31+
} else {
32+
console.log(`Check of circular deps after filtering white list: `, filteredResult);
33+
}
34+
}
35+
36+
(async () => await checkAppForCircualr(androidApp, androidWhiteList))();
37+
(async () => await checkAppForCircualr(iosApp, iosWhiteList))();

tests/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@
2424
"lazy": "1.0.11",
2525
"tns-platform-declarations": "*",
2626
"typescript": "^3.1.6"
27+
},
28+
"scripts": {
29+
"check-circular-deps": "node circular-check.js"
2730
}
28-
}
31+
}

0 commit comments

Comments
 (0)