File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -261,9 +261,27 @@ function getCliParameters() {
261
261
parameters [ key . replace ( '--' , '' ) ] = value || true ;
262
262
} ) ;
263
263
264
+ // Sanitize ci validation input
265
+ const ciValidationParam = parameters [ 'ci-validation' ] ;
266
+ if ( ciValidationParam && ( typeof ciValidationParam !== 'boolean' ) ) {
267
+ console . warn ( `❌ Must not offer any value for --ci-validation.` ) ;
268
+ process . exit ( 1 ) ;
269
+ }
270
+
271
+ // Sanitize languages input, removing empty strings and using the default value if none provided
272
+ const strictLanguagesParam = parameters [ 'strict-languages' ] ;
273
+ if ( strictLanguagesParam && ( typeof strictLanguagesParam !== 'string' ) ) {
274
+ console . warn ( `❌ Invalid value for --strict-languages. Usage: node update_translations.js --ci-validation --strict-languages=ru-ru,da` ) ;
275
+ process . exit ( 1 ) ;
276
+ }
277
+ const sanitizedLanguagesInput = strictLanguagesParam ?. split ( ',' ) . filter ( ( lang ) => lang ) || [ ] ;
278
+ const treatedLanguagesParam = sanitizedLanguagesInput ?. length
279
+ ? sanitizedLanguagesInput
280
+ : mandatoryTranslations ;
281
+
264
282
return {
265
- isCiValidationRun : parameters [ 'ci-validation' ] || false ,
266
- strictLanguages : parameters [ 'strict-languages' ] ?. split ( ',' ) || mandatoryTranslations ,
283
+ isCiValidationRun : ciValidationParam || false ,
284
+ strictLanguages : treatedLanguagesParam ,
267
285
}
268
286
}
269
287
You can’t perform that action at this time.
0 commit comments