refactor: use the lastInput arg to compute the prepare pipeline next input

Use the `getNextInput`'s provided argument rather than relying on the closure.
This commit is contained in:
Pierre Vanduynslager 2018-07-06 23:49:09 -04:00
parent 12de6282dd
commit f7f4aabe9e

View File

@ -114,17 +114,17 @@ async function run(options, plugins) {
await plugins.prepare(
{options, logger, lastRelease, commits, nextRelease},
{
getNextInput: async lastResult => {
getNextInput: async ({nextRelease, ...prepareParam}) => {
const newGitHead = await getGitHead();
// If previous prepare plugin has created a commit (gitHead changed)
if (lastResult.nextRelease.gitHead !== newGitHead) {
if (nextRelease.gitHead !== newGitHead) {
nextRelease.gitHead = newGitHead;
// Regenerate the release notes
logger.log('Call plugin %s', 'generateNotes');
[nextRelease.notes] = await plugins.generateNotes(generateNotesParam);
[nextRelease.notes] = await plugins.generateNotes({nextRelease, ...prepareParam});
}
// Call the next publish plugin with the updated `nextRelease`
return {options, logger, lastRelease, commits, nextRelease};
return {...prepareParam, nextRelease};
},
}
);