Skip to content

Commit 18e7431

Browse files
Make conditional easier to read
1 parent 6504e46 commit 18e7431

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

extensions/ql-vscode/src/queries-panel/query-pack-discovery.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,20 @@ export class QueryPackDiscovery extends FilePathDiscovery<QueryPack> {
4848
return undefined;
4949
}
5050

51+
if (packs.length === 1) {
52+
return packs[0].language;
53+
}
54+
55+
// If the first two packs are from a different directory, then the first one is the nearest
56+
if (dirname(packs[0].path) !== dirname(packs[1].path)) {
57+
return packs[0].language;
58+
}
59+
5160
// If the first two packs are from the same directory then look at the filenames
52-
if (
53-
packs.length >= 2 &&
54-
dirname(packs[0].path) === dirname(packs[1].path)
55-
) {
56-
if (basename(packs[0].path) === FALLBACK_QLPACK_FILENAME) {
57-
return packs[0].language;
58-
} else {
59-
return packs[1].language;
60-
}
61-
} else {
61+
if (basename(packs[0].path) === FALLBACK_QLPACK_FILENAME) {
6262
return packs[0].language;
63+
} else {
64+
return packs[1].language;
6365
}
6466
}
6567

0 commit comments

Comments
 (0)