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 ) ) ( ) ;
0 commit comments