Skip to content

Commit baac929

Browse files
committed
Check both qlpack.yml and codeql-pack.yml
1 parent 57f4ac5 commit baac929

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/init.test.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ type PackInfo = {
144144
language: KnownLanguage;
145145
packinfoContents: string | undefined;
146146
sourceOnlyPack?: boolean;
147+
qlpackFileName?: string;
147148
};
148149

149150
const testCheckPacksForOverlayCompatibility = test.macro({
@@ -174,8 +175,9 @@ const testCheckPacksForOverlayCompatibility = test.macro({
174175
packInfo.packinfoContents,
175176
);
176177
}
178+
const qlpackFileName = packInfo.qlpackFileName || "qlpack.yml";
177179
fs.writeFileSync(
178-
path.join(packPath, "qlpack.yml"),
180+
path.join(packPath, qlpackFileName),
179181
packInfo.sourceOnlyPack
180182
? `name: ${packName}\nversion: 1.0.0\n`
181183
: `name: ${packName}\nversion: 1.0.0\nbuildMetadata:\n sha: 123abc\n`,
@@ -423,3 +425,20 @@ test(
423425
expectedResult: false,
424426
},
425427
);
428+
429+
test(
430+
testCheckPacksForOverlayCompatibility,
431+
"returns true when query pack uses codeql-pack.yml filename",
432+
{
433+
cliOverlayVersion: 2,
434+
languages: [KnownLanguage.java],
435+
packs: {
436+
"codeql/java-queries": {
437+
language: KnownLanguage.java,
438+
packinfoContents: '{"overlayVersion":2}',
439+
qlpackFileName: "codeql-pack.yml",
440+
},
441+
},
442+
expectedResult: true,
443+
},
444+
);

src/init.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ function checkPackForOverlayCompatibility(
153153
logger: Logger,
154154
): boolean {
155155
try {
156-
const qlpackPath = path.join(packDir, "qlpack.yml");
156+
let qlpackPath = path.join(packDir, "qlpack.yml");
157+
if (!fs.existsSync(qlpackPath)) {
158+
qlpackPath = path.join(packDir, "codeql-pack.yml");
159+
}
157160
const qlpackContents = yaml.load(
158161
fs.readFileSync(qlpackPath, "utf8"),
159162
) as QlPack;

0 commit comments

Comments
 (0)