Skip to content

Commit

Permalink
Merge pull request #1571 from intuit/all-contributors-logging
Browse files Browse the repository at this point in the history
add logging if all-contributors rc isn't found or has errors
  • Loading branch information
hipstersmoothie committed Oct 7, 2020
2 parents b2d58ed + 15523e8 commit f7ff37b
Showing 1 changed file with 17 additions and 4 deletions.
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

0 comments on commit f7ff37b

Please sign in to comment.