mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
test: circular deps
This commit is contained in:
37
tests/circular-check.js
Normal file
37
tests/circular-check.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
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',
|
||||||
|
'http/http.js',
|
||||||
|
'http/http-request/http-request.js'];
|
||||||
|
|
||||||
|
const androidWhiteList = ['ui/frame/frame.js', 'ui/frame/fragment.js'];
|
||||||
|
|
||||||
|
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) : circular);
|
||||||
|
|
||||||
|
if (circular && circular.length > 0 && filteredResult.length > 0) {
|
||||||
|
console.log(`Found circular deps!`, filteredResult);
|
||||||
|
process.exit(1);
|
||||||
|
} else {
|
||||||
|
console.log(`Check of circular deps after filtering white list: `, filteredResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(async () => await checkAppForCircualr(androidApp, androidWhiteList))();
|
||||||
|
(async () => await checkAppForCircualr(iosApp, iosWhiteList))();
|
@ -24,5 +24,8 @@
|
|||||||
"lazy": "1.0.11",
|
"lazy": "1.0.11",
|
||||||
"tns-platform-declarations": "*",
|
"tns-platform-declarations": "*",
|
||||||
"typescript": "^3.1.6"
|
"typescript": "^3.1.6"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"check-circular-deps": "node circular-check.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user