@@ -76,14 +76,14 @@ function getASConfig(asconfigPath, targetName, readFile, configuration, cliOptio
76
76
// }
77
77
78
78
// if no options are provided in the configuration, return early
79
- if ( ! config . options ) return ;
79
+ if ( ! config . options && ! config . targets ) return ;
80
80
81
81
// first reconcile the top level options
82
82
if ( config . options ) {
83
83
reconcile ( cliOptions , config . options , configuration , overrides ) ;
84
84
}
85
85
86
- // then reconvile the target
86
+ // then reconcile the target
87
87
if ( config . targets && config . targets [ targetName ] ) {
88
88
reconcile ( cliOptions , config . targets [ targetName ] , configuration , overrides ) ;
89
89
}
@@ -101,7 +101,7 @@ exports.getASConfig = getASConfig;
101
101
// V | array of values (provided in "values" property)
102
102
103
103
function validateOptionsObject ( options , configDefinition ) {
104
- for ( const key of Object . keys ( configDefinition ) ) {
104
+ for ( const key of Object . getOwnPropertyNames ( configDefinition ) ) {
105
105
const type = configDefinition [ key ] . type ;
106
106
if ( ! ( key in options ) ) continue ;
107
107
switch ( type ) {
@@ -145,6 +145,11 @@ function validateOptionsObject(options, configDefinition) {
145
145
default : throw new Error ( "Invalid asconfig option type '" + type + "'." ) ;
146
146
}
147
147
}
148
+
149
+ for ( const key of Object . getOwnPropertyNames ( options ) ) {
150
+ // console.log(options);
151
+ if ( ! configDefinition [ key ] ) throw new Error ( "Invalid asconfig option '" + key + "'." ) ;
152
+ }
148
153
}
149
154
150
155
function validate ( contents , configDefinition ) {
@@ -157,10 +162,11 @@ function validate(contents, configDefinition) {
157
162
// if (path.extname(config.extends) !== ".json") throw new Error( "Configuration must extend a json file.");
158
163
// }
159
164
if ( config . targets ) {
160
- if ( ! Array . isArray ( config . targets ) ) throw new Error ( "Configuration targets value must be an Array." ) ;
161
- config . targets . forEach ( target => {
162
- if ( typeof target . name !== "string" ) throw new Error ( "All configuration targets must have a name." ) ;
163
- } ) ;
165
+ if ( typeof config . targets !== "object" ) throw new Error ( "Configuration property 'targets' must be an Object." ) ;
166
+
167
+ for ( const key of Object . getOwnPropertyNames ( config . targets ) ) {
168
+ if ( typeof config . targets [ key ] !== "object" ) throw new Error ( "Configuration target '" + key + "' must be an Object." ) ;
169
+ }
164
170
}
165
171
166
172
// validate the options object
0 commit comments