@@ -15,21 +15,21 @@ class DeploymentConfig {
1515 static {
1616 const deploymentConfigPath = process . env . DEPLOYMENT_CONFIG_FILE ? process . env . DEPLOYMENT_CONFIG_FILE : 'deployment-settings.yml'
1717 if ( fs . existsSync ( deploymentConfigPath ) ) {
18- this . config = yaml . load ( fs . readFileSync ( deploymentConfigPath ) )
18+ this . config = yaml . load ( fs . readFileSync ( deploymentConfigPath ) ) || { }
1919 } else {
2020 this . config = { restrictedRepos : [ 'admin' , '.github' , 'safe-settings' ] }
2121 }
2222
23- const overridevalidators = this . config . overridevalidators
24- if ( this . isIterable ( overridevalidators ) ) {
23+ const overridevalidators = this . config . overridevalidators || [ ]
24+ if ( this . isNonEmptyArray ( overridevalidators ) ) {
2525 for ( const validator of overridevalidators ) {
2626 // eslint-disable-next-line no-new-func
2727 const f = new Function ( 'baseconfig' , 'overrideconfig' , 'githubContext' , validator . script )
2828 this . overridevalidators [ validator . plugin ] = { canOverride : f , error : validator . error }
2929 }
3030 }
31- const configvalidators = this . config . configvalidators
32- if ( this . isIterable ( configvalidators ) ) {
31+ const configvalidators = this . config . configvalidators || [ ]
32+ if ( this . isNonEmptyArray ( configvalidators ) ) {
3333 for ( const validator of configvalidators ) {
3434 // eslint-disable-next-line no-new-func
3535 const f = new Function ( 'baseconfig' , 'githubContext' , validator . script )
@@ -38,12 +38,8 @@ class DeploymentConfig {
3838 }
3939 }
4040
41- static isIterable ( obj ) {
42- // checks for null and undefined
43- if ( obj == null ) {
44- return false
45- }
46- return typeof obj [ Symbol . iterator ] === 'function'
41+ static isNonEmptyArray ( obj ) {
42+ return Array . isArray ( obj ) && obj . length > 0
4743 }
4844
4945 // eslint-disable-next-line no-useless-constructor
0 commit comments