@@ -15,21 +15,21 @@ class DeploymentConfig {
15
15
static {
16
16
const deploymentConfigPath = process . env . DEPLOYMENT_CONFIG_FILE ? process . env . DEPLOYMENT_CONFIG_FILE : 'deployment-settings.yml'
17
17
if ( fs . existsSync ( deploymentConfigPath ) ) {
18
- this . config = yaml . load ( fs . readFileSync ( deploymentConfigPath ) )
18
+ this . config = yaml . load ( fs . readFileSync ( deploymentConfigPath ) ) || { }
19
19
} else {
20
20
this . config = { restrictedRepos : [ 'admin' , '.github' , 'safe-settings' ] }
21
21
}
22
22
23
- const overridevalidators = this . config . overridevalidators
24
- if ( this . isIterable ( overridevalidators ) ) {
23
+ const overridevalidators = this . config . overridevalidators || [ ]
24
+ if ( this . isNonEmptyArray ( overridevalidators ) ) {
25
25
for ( const validator of overridevalidators ) {
26
26
// eslint-disable-next-line no-new-func
27
27
const f = new Function ( 'baseconfig' , 'overrideconfig' , 'githubContext' , validator . script )
28
28
this . overridevalidators [ validator . plugin ] = { canOverride : f , error : validator . error }
29
29
}
30
30
}
31
- const configvalidators = this . config . configvalidators
32
- if ( this . isIterable ( configvalidators ) ) {
31
+ const configvalidators = this . config . configvalidators || [ ]
32
+ if ( this . isNonEmptyArray ( configvalidators ) ) {
33
33
for ( const validator of configvalidators ) {
34
34
// eslint-disable-next-line no-new-func
35
35
const f = new Function ( 'baseconfig' , 'githubContext' , validator . script )
@@ -38,12 +38,8 @@ class DeploymentConfig {
38
38
}
39
39
}
40
40
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
47
43
}
48
44
49
45
// eslint-disable-next-line no-useless-constructor
0 commit comments