Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add logging if all-contributors rc isn't found or has errors #1571

Merged
merged 1 commit into from
Oct 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions plugins/all-contributors/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,28 @@ const isContribution = (
contributionTypes.includes(contribution as Contribution);

/** Get an rc file if there is one. */
function getRcFile() {
function getRcFile(auto: Auto) {
const rcFile = path.join(process.cwd(), ".all-contributorsrc");

if (!fs.existsSync(rcFile)) {
auto.logger.verbose.warn(
`No all-contributors configuration file found at: ${rcFile}`
);
return;
}

try {
const rcFile = path.join(process.cwd(), ".all-contributorsrc");
const config: AllContributorsRc = JSON.parse(
fs.readFileSync(rcFile, "utf8")
);

return { ...config, config: rcFile };
} catch (error) {}
} catch (error) {
auto.logger.log.error(
`Encountered errors loading all-contributors configuration at ${rcFile}`,
error
);
}
}

const pattern = t.union([t.string, t.array(t.string)]);
Expand Down Expand Up @@ -363,7 +376,7 @@ export default class AllContributorsPlugin implements IPlugin {

/** Update the contributors rc for a package. */
private async updateContributors(auto: Auto, commits: IExtendedCommit[]) {
const config = getRcFile();
const config = getRcFile(auto);

if (!config) {
return;
Expand Down