@@ -35,6 +35,15 @@ export type QLDebugConfiguration = DebugConfiguration & QLDebugArgs;
3535export type QLResolvedDebugConfiguration = DebugConfiguration &
3636 CodeQLProtocol . LaunchConfig ;
3737
38+ /** If the specified value is a single element, then turn it into an array containing that element. */
39+ function makeArray < T extends Exclude < any , any [ ] > > ( value : T | T [ ] ) : T [ ] {
40+ if ( Array . isArray ( value ) ) {
41+ return value ;
42+ } else {
43+ return [ value ] ;
44+ }
45+ }
46+
3847/**
3948 * Implementation of `DebugConfigurationProvider` for CodeQL.
4049 */
@@ -83,21 +92,16 @@ export class QLDebugConfigurationProvider
8392
8493 // Fill in defaults here, instead of in `resolveDebugConfiguration`, to avoid the highly
8594 // unusual case where one of the computed default values looks like a variable substitution.
86- const additionalPacks =
87- qlConfiguration . additionalPacks === undefined
88- ? getOnDiskWorkspaceFolders ( )
89- : typeof qlConfiguration . additionalPacks === "string"
90- ? [ qlConfiguration . additionalPacks ]
91- : qlConfiguration . additionalPacks ;
95+ const additionalPacks = makeArray (
96+ qlConfiguration . additionalPacks ?? getOnDiskWorkspaceFolders ( ) ,
97+ ) ;
9298
9399 // Default to computing the extension packs based on the extension configuration and the search
94100 // path.
95- const extensionPacks =
96- qlConfiguration . extensionPacks === undefined
97- ? await this . localQueries . getDefaultExtensionPacks ( additionalPacks )
98- : typeof qlConfiguration . extensionPacks === "string"
99- ? [ qlConfiguration . extensionPacks ]
100- : qlConfiguration . extensionPacks ;
101+ const extensionPacks = makeArray (
102+ qlConfiguration . extensionPacks ??
103+ ( await this . localQueries . getDefaultExtensionPacks ( additionalPacks ) ) ,
104+ ) ;
101105
102106 const quickEval = qlConfiguration . quickEval ?? false ;
103107 validateQueryPath ( qlConfiguration . query , quickEval ) ;
0 commit comments