Packaging: Address review comments

1. Better malformed data guard for PackDownloadOutput
2. Fix Packs type
3. Remove TODO in init-action
This commit is contained in:
Andrew Eisenberg 2021-06-07 16:05:32 -07:00
parent d87945e9fd
commit 1cc5f1d5dd
14 changed files with 39 additions and 69 deletions

View file

@ -796,10 +796,18 @@ function getCodeQLForCmd(cmd: string): CodeQL {
}).exec();
try {
return JSON.parse(output) as PackDownloadOutput;
const parsedOutput: PackDownloadOutput = JSON.parse(output);
if (
Array.isArray(parsedOutput.packs) &&
parsedOutput.packs.every((p) => p.name && p.version)
) {
return parsedOutput;
} else {
throw new Error("Unexpected output from pack download");
}
} catch (e) {
throw new Error(
`Attempted to download specified packs but got an error:${"\n"}${output}.`
`Attempted to download specified packs but got an error:\n${output}\n${e}`
);
}
},