Skip to content

Commit ed4b296

Browse files
committed
Allow empty qlpack files
1 parent e5ffdd0 commit ed4b296

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

extensions/ql-vscode/src/packaging/qlpack-file-loader.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ const ajv = new Ajv({ allErrors: true });
88
const qlpackFileValidate = ajv.compile(qlpackFileSchemaJson);
99

1010
export async function loadQlpackFile(path: string): Promise<QlPackFile> {
11-
const qlPack = load(await readFile(path, "utf8")) as QlPackFile | undefined;
11+
const qlpackFileText = await readFile(path, "utf8");
12+
13+
let qlPack = load(qlpackFileText) as QlPackFile | undefined;
14+
15+
if (qlPack === undefined || qlPack === null) {
16+
// An empty file is not valid according to the schema since it's not an object,
17+
// but it is equivalent to an empty object.
18+
qlPack = {};
19+
}
1220

1321
qlpackFileValidate(qlPack);
1422

@@ -20,9 +28,5 @@ export async function loadQlpackFile(path: string): Promise<QlPackFile> {
2028
);
2129
}
2230

23-
if (!qlPack) {
24-
throw new Error(`Could not parse ${path}`);
25-
}
26-
2731
return qlPack;
2832
}

0 commit comments

Comments
 (0)