@@ -20,25 +20,33 @@ export namespace GithubService {
2020 await _checkTestDirectory ( ) ;
2121 const projectName = dirNameFromPluginName ( plugin . name ) ;
2222 await _cloneProject ( plugin . repositoryUrl , projectName ) ;
23- const demoDir = _getDemoDir ( path . join ( testDirectory , projectName ) , plugin ) ;
24- result . demoDirectory = demoDir ;
25-
26- if ( plugin . badges . androidVersion || plugin . badges . iosVersion ) {
27- await _prepareDemoProject ( demoDir , plugin . name ) ;
28- }
29-
30- if ( plugin . badges . androidVersion ) {
31- result . android = ! ! ( await _buildProject ( demoDir , 'android' ) ) ;
32- hasPlatform = true ;
33- }
34-
35- if ( plugin . badges . iosVersion ) {
36- result . ios = ! ! ( await _buildProject ( demoDir , 'ios' ) ) ;
37- hasPlatform = true ;
38- }
39-
40- if ( ! hasPlatform ) {
41- Logger . error ( 'plugin has no platform' ) ;
23+ const demoDirs = _getDemoDirs ( path . join ( testDirectory , projectName ) ) ;
24+ for ( let i = 0 ; i < demoDirs . length ; i ++ ) {
25+ const demoDir = demoDirs [ i ] ;
26+ result . demoDirectory = demoDir ;
27+ if ( plugin . badges . androidVersion || plugin . badges . iosVersion ) {
28+ await _prepareDemoProject ( demoDir , plugin . name ) ;
29+ }
30+
31+ if ( plugin . badges . androidVersion ) {
32+ result . android = ! ! ( await _buildProject ( demoDir , 'android' ) ) ;
33+ hasPlatform = true ;
34+ }
35+
36+ if ( plugin . badges . iosVersion ) {
37+ result . ios = ! ! ( await _buildProject ( demoDir , 'ios' ) ) ;
38+ hasPlatform = true ;
39+ }
40+
41+ if ( ! hasPlatform ) {
42+ Logger . error ( 'plugin has no platform' ) ;
43+ break ;
44+ }
45+
46+ if ( result . android || result . ios ) {
47+ // successful demo build
48+ break ;
49+ }
4250 }
4351 } catch ( errExec ) {
4452 Logger . error ( JSON . stringify ( errExec . message || errExec ) ) ;
@@ -47,17 +55,17 @@ export namespace GithubService {
4755 return result ;
4856 }
4957
50- function _getDemoDir ( name : string , plugin : MarketplaceService . PluginModel ) {
58+ function _getDemoDirs ( parentDir : string ) {
5159 const dirs = [ 'demo' , 'demo-ts' , 'demo-angular' , 'demo-ng' , 'ng-demo' , 'demo-vue' ] ;
60+ const available = [ ] ;
5261 for ( let index = 0 ; index < dirs . length ; index ++ ) {
5362 const element = dirs [ index ] ;
54- if ( existsSync ( path . join ( name , element ) ) ) {
55- name = path . join ( name , element ) ;
56- break ;
63+ if ( existsSync ( path . join ( parentDir , element ) ) ) {
64+ available . push ( path . join ( parentDir , element ) ) ;
5765 }
5866 }
5967
60- return name ;
68+ return available ;
6169 }
6270
6371 async function _prepareDemoProject ( cwd : string , name : string ) {
0 commit comments