Skip to content

Commit

Permalink
move promise all into function
Browse files Browse the repository at this point in the history
  • Loading branch information
kendallgassner committed Oct 8, 2020
1 parent f9f3daf commit d55c93d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions plugins/all-contributors/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function getExtraContributors(body?: string) {

/** Determine which files need to display contributors and generate contributors */
function generateContributorReadme(config: AllContributorsRc, contributors: any) {
return (config.files || ["README.md"]).map(async (file) => {
return Promise.all((config.files || ["README.md"]).map(async (file) => {
const oldReadMe = fs.readFileSync(file, {
encoding: "utf-8",
});
Expand All @@ -190,7 +190,7 @@ function generateContributorReadme(config: AllContributorsRc, contributors: any)
oldReadMe
);
fs.writeFileSync(file, newReadMe);
})
}));
}

/** Automatically add contributors as changelogs are produced. */
Expand Down Expand Up @@ -511,9 +511,8 @@ export default class AllContributorsPlugin implements IPlugin {
);
this.generatedReadme = true;
// Update files that contain contributors table
await Promise.all(
generateContributorReadme(config, contributors)
);
await generateContributorReadme(config, contributors)

}
else {
auto.logger.verbose.warn(`"${username}" had no new contributions...`);
Expand All @@ -533,9 +532,8 @@ export default class AllContributorsPlugin implements IPlugin {
);

if (notInitalized && file) {
await Promise.all(
generateContributorReadme(config, undefined)
);
await generateContributorReadme(config, undefined)

}
} catch { }
}
Expand Down

0 comments on commit d55c93d

Please sign in to comment.