Skip to content

Commit

Permalink
feat: allow to run prepare steps sequentially
Browse files Browse the repository at this point in the history
  • Loading branch information
KillianHmyd authored and antongolub committed Apr 13, 2021
1 parent cdd2f8b commit 299748a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/createInlinePluginCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { updateManifestDeps, resolveReleaseType } = require("./updateDeps");
function createInlinePluginCreator(packages, multiContext, synchronizer, flags) {
// Vars.
const { cwd } = multiContext;
const { todo, waitFor, waitForAll, emit, getLucky } = synchronizer;
const { todo, waitFor, waitForAll, emit, getLucky, waitLocalDeps } = synchronizer;

/**
* Create an inline plugin for an individual package in a multirelease.
Expand Down Expand Up @@ -181,6 +181,11 @@ function createInlinePluginCreator(packages, multiContext, synchronizer, flags)
};

const prepare = async (pluginOptions, context) => {
if (pkg.options.sequentialPrepare) {
debug(debugPrefix, "waiting local dependencies preparation");
await waitLocalDeps("_prepared", pkg);
}

// Wait until the current pkg is ready to be tagged
getLucky("_readyForTagging", pkg);
await waitFor("_readyForTagging", pkg);
Expand All @@ -196,6 +201,7 @@ function createInlinePluginCreator(packages, multiContext, synchronizer, flags)
pkg._prepared = true;

debug(debugPrefix, "prepared");
emit("_prepared", pkg);

return res;
};
Expand Down
8 changes: 8 additions & 0 deletions lib/getSynchronizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ const getSynchronizer = (packages) => {
getLucky[probe] = emit(probe, pkg);
};

// Wait that all local deps passes the probe
const waitLocalDeps = (probe, pkg) => {
return Promise.all(pkg.localDeps.map((d) => waitFor(probe, d))).then(() => {
debug(`[${pkg.name}]`, `all local dependencies emitted ${probe}`);
});
};

return {
ee,
emit,
Expand All @@ -82,6 +89,7 @@ const getSynchronizer = (packages) => {
waitFor,
waitForAll,
getLucky,
waitLocalDeps,
};
};

Expand Down

0 comments on commit 299748a

Please sign in to comment.