mirror of
https://github.com/status-im/sourcecred.git
synced 2025-02-17 06:56:36 +00:00
Fix flow errors in fetchAndPrintGithubRepo.js (#240)
Fixing the flow error corresponded to (correctly) documenting that the GitHub token is mandatory, not optional. Test plan: `yarn travis --full` still passes.
This commit is contained in:
parent
d34503799c
commit
1647c1abac
@ -1,4 +1,4 @@
|
|||||||
// @no-flow
|
// @flow
|
||||||
/*
|
/*
|
||||||
* Command-line utility to fetch GitHub data using the API in
|
* Command-line utility to fetch GitHub data using the API in
|
||||||
* ../fetchGithubRepo, and print it to stdout. Useful for testing or
|
* ../fetchGithubRepo, and print it to stdout. Useful for testing or
|
||||||
@ -19,16 +19,14 @@ function parseArgs() {
|
|||||||
const argv = process.argv.slice(2);
|
const argv = process.argv.slice(2);
|
||||||
const fail = () => {
|
const fail = () => {
|
||||||
const invocation = process.argv.slice(0, 2).join(" ");
|
const invocation = process.argv.slice(0, 2).join(" ");
|
||||||
throw new Error(`Usage: ${invocation} REPO_OWNER REPO_NAME [TOKEN]`);
|
throw new Error(`Usage: ${invocation} REPO_OWNER REPO_NAME GITHUB_TOKEN`);
|
||||||
};
|
};
|
||||||
if (argv.length < 2) {
|
if (argv.length < 2) {
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
const [repoOwner, repoName, ...rest] = argv;
|
const [repoOwner, repoName, githubToken, ...rest] = argv;
|
||||||
const result = {repoOwner, repoName};
|
const result = {repoOwner, repoName, githubToken};
|
||||||
if (rest.length === 1) {
|
if (rest.length > 0) {
|
||||||
result.token = rest[0];
|
|
||||||
} else if (rest.length > 1) {
|
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -36,7 +34,7 @@ function parseArgs() {
|
|||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
const args = parseArgs();
|
const args = parseArgs();
|
||||||
fetchGithubRepo(args.repoOwner, args.repoName, args.token)
|
fetchGithubRepo(args.repoOwner, args.repoName, args.githubToken)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log(stringify(data, {space: 4}));
|
console.log(stringify(data, {space: 4}));
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user