mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge pull request #6824 from NativeScript/svetoslavtsenov/tests-app-circular-deps-check
test: circular deps
This commit is contained in:
41
tests/circular-check.js
Normal file
41
tests/circular-check.js
Normal file
@@ -0,0 +1,41 @@
|
||||
const madge = require('madge');
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
|
||||
const workingDirecotry = process.cwd();
|
||||
const androidApp = path.join(workingDirecotry, "platforms/android/app/src/main/assets/app/tns_modules/tns-core-modules");
|
||||
const iosApp = path.join(workingDirecotry, "platforms/ios/tests/app/tns_modules/tns-core-modules");
|
||||
|
||||
const iosWhiteList = ['image-source/image-source.js'];
|
||||
const androidWhiteList = ['image-source/image-source.js', 'ui/frame/frame.js'];
|
||||
|
||||
const printResult = (allCircleDeps) => {
|
||||
allCircleDeps.forEach(circleDeps => {
|
||||
const log = circleDeps.join(" -> ");
|
||||
console.log(log);
|
||||
});
|
||||
}
|
||||
|
||||
const checkAppForCircualr = async (appName, whiteList) => {
|
||||
if (!fs.existsSync(appName)) {
|
||||
console.error(`${appName} doesn't exists!`);
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await madge(appName);
|
||||
const circular = result.circular();
|
||||
console.info(`Check ${appName}`);
|
||||
console.log(`Initial check: `, circular);
|
||||
|
||||
const filteredResult = circular && circular.length > 0 && (whiteList ? circular.filter(c => whiteList.indexOf(c[0]) < 0) : circular);
|
||||
|
||||
if (circular && circular.length > 0 && filteredResult.length > 0) {
|
||||
|
||||
console.log(`Found circular deps!`);
|
||||
printResult(filteredResult);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
(async () => await checkAppForCircualr(androidApp, androidWhiteList))();
|
||||
(async () => await checkAppForCircualr(iosApp, iosWhiteList))();
|
||||
@@ -24,5 +24,8 @@
|
||||
"lazy": "1.0.11",
|
||||
"tns-platform-declarations": "*",
|
||||
"typescript": "^3.1.6"
|
||||
},
|
||||
"scripts": {
|
||||
"check-circular-deps": "node circular-check.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user