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

11
lib/codeql.js generated
View file

@ -526,10 +526,17 @@ function getCodeQLForCmd(cmd) {
},
}).exec();
try {
return JSON.parse(output);
const parsedOutput = 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}.`);
throw new Error(`Attempted to download specified packs but got an error:\n${output}\n${e}`);
}
},
};