@@ -26,13 +26,29 @@ export interface QuerySpec {
2626 uses : string ;
2727}
2828
29+ // We generally accept simple strings or `QuerySpec` objects as inputs for extra queries.
30+ export type QueryInput = QuerySpec | string ;
31+
32+ /**
33+ * A helper function for log messages that turns a `QueryInput` into a `string`.
34+ *
35+ * @param input The `QueryInput` to display.
36+ * @returns A string representation of `QueryInput`.
37+ */
38+ export function renderQueryInput ( input : QueryInput ) : string {
39+ if ( typeof input === "string" ) {
40+ return input ;
41+ }
42+ return input . uses ;
43+ }
44+
2945/**
3046 * Format of the config file supplied by the user.
3147 */
3248export interface UserConfig {
3349 name ?: string ;
3450 "disable-default-queries" ?: boolean ;
35- queries ?: QuerySpec [ ] ;
51+ queries ?: QueryInput [ ] ;
3652 "paths-ignore" ?: string [ ] ;
3753 paths ?: string [ ] ;
3854
@@ -374,8 +390,8 @@ function combineQueries(
374390 logger : Logger ,
375391 config : UserConfig ,
376392 augmentationProperties : AugmentationProperties ,
377- ) : QuerySpec [ ] {
378- const result : QuerySpec [ ] = [ ] ;
393+ ) : QueryInput [ ] {
394+ const result : QueryInput [ ] = [ ] ;
379395
380396 // Query settings obtained from the repository properties have the highest precedence.
381397 if (
@@ -440,7 +456,7 @@ export function generateCodeScanningConfig(
440456 augmentationProperties ,
441457 ) ;
442458 logger . debug (
443- `Combined queries: ${ augmentedConfig . queries ?. map ( ( q ) => q . uses ) . join ( "," ) } ` ,
459+ `Combined queries: ${ augmentedConfig . queries ?. map ( renderQueryInput ) . join ( "," ) } ` ,
444460 ) ;
445461 if ( augmentedConfig . queries ?. length === 0 ) {
446462 delete augmentedConfig . queries ;
0 commit comments