Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add better comments and error messages for pack-related changes
  • Loading branch information
Andrew Eisenberg committed Jun 4, 2021
1 parent 86a804f commit 6cee818
Showing 9 changed files with 35 additions and 17 deletions.
16 changes: 11 additions & 5 deletions lib/codeql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion lib/config-utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/config-utils.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/config-utils.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/config-utils.test.js.map

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions src/codeql.ts
@@ -767,10 +767,16 @@ function getCodeQLForCmd(cmd: string): CodeQL {
return output;
},

// Download specified packs into the package cache. If the specified
// package and version already exists (e.g., from a previous analysis run),
// then it is not downloaded again (unless the extra option `--force` is
// specified).
/**
* Download specified packs into the package cache. If the specified
* package and version already exists (e.g., from a previous analysis run),
* then it is not downloaded again (unless the extra option `--force` is
* specified).
*
* If no version is specified, then the latest version is
* downloaded. The check to determine what the latest version is is done
* each time this package is requested.
*/
async packDownload(packs: PackWithVersion[]): Promise<PackDownloadOutput> {
const args = [
"pack",
@@ -793,7 +799,7 @@ function getCodeQLForCmd(cmd: string): CodeQL {
return JSON.parse(output) as PackDownloadOutput;
} catch (e) {
throw new Error(
`Attempted to download specified packs but got error ${e}.`
`Attempted to download specified packs but got an error:${"\n"}${output}.`
);
}
},
2 changes: 1 addition & 1 deletion src/config-utils.test.ts
@@ -1411,7 +1411,7 @@ test(
/The configuration file "\/a\/b" is invalid: property "packs" must be an array of non-empty strings/
);

test(invalidPackNameMacro, "c");
test(invalidPackNameMacro, "c"); // all packs require at least a scope and a name
test(invalidPackNameMacro, "c-/d");
test(invalidPackNameMacro, "-c/d");
test(invalidPackNameMacro, "c/d_d");
5 changes: 4 additions & 1 deletion src/config-utils.ts
@@ -1016,7 +1016,10 @@ async function loadConfig(
};
}

// Only alpha-numeric characters, with `-` allowed as long as not the first or last char
/**
* Pack names must be in the form of `scope/name`, with only alpha-numeric characters,
* and `-` allowed as long as not the first or last char.
**/
const PACK_IDENTIFIER_PATTERN = (function () {
const alphaNumeric = "[a-z0-9]";
const alphaNumericDash = "[a-z0-9-]";

0 comments on commit 6cee818

Please sign in to comment.