Skip to content

Commit

Permalink
fix(sequential-prepare): do not wait forever when a child package has…
Browse files Browse the repository at this point in the history
… no change
  • Loading branch information
KillianHmyd authored and antongolub committed Apr 16, 2021
1 parent 6288293 commit 713046a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/createInlinePluginCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ function createInlinePluginCreator(packages, multiContext, synchronizer, flags)
debug(debugPrefix, "commits analyzed");
debug(debugPrefix, `release type: ${pkg._nextType}`);

// if the package won't be released consider it as prepared
if (!pkg._nextType) {
emit("_prepared", pkg);
}

// Return type.
return pkg._nextType;
};
Expand Down
61 changes: 61 additions & 0 deletions test/lib/multiSemanticRelease.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,67 @@ describe("multiSemanticRelease()", () => {
});
});

test("Changes in parent packages with sequentialPrepare", async () => {
// Create Git repo.
const cwd = gitInit();
// Initial commit.
copyDirectory(`test/fixtures/yarnWorkspaces2Packages/`, cwd);
const sha1 = gitCommitAll(cwd, "feat: Initial release");
gitTag(cwd, "msr-test-c@1.0.0");
gitTag(cwd, "msr-test-d@1.0.0");
// Second commit.
writeFileSync(`${cwd}/packages/c/aaa.txt`, "AAA");
const sha2 = gitCommitAll(cwd, "feat(aaa): Add missing text file");
const url = gitInitOrigin(cwd);
gitPush(cwd);

// Capture output.
const stdout = new WritableStreamBuffer();
const stderr = new WritableStreamBuffer();

// Call multiSemanticRelease()
// Doesn't include plugins that actually publish.
const multiSemanticRelease = require("../../");
const result = await multiSemanticRelease(
[`packages/c/package.json`, `packages/d/package.json`],
{},
{ cwd, stdout, stderr },
{ deps: {}, dryRun: false, sequentialPrepare: true }
);

// Get stdout and stderr output.
const err = stderr.getContentsAsString("utf8");
expect(err).toBe(false);
const out = stdout.getContentsAsString("utf8");
expect(out).toMatch("Started multirelease! Loading 2 packages...");
expect(out).toMatch("Loaded package msr-test-c");
expect(out).toMatch("Loaded package msr-test-d");
expect(out).toMatch("Queued 2 packages! Starting release...");
expect(out).toMatch("Created tag msr-test-c@1.1.0");
expect(out).toMatch("Released 1 of 2 packages, semantically!");

// C.
expect(result[0].name).toBe("msr-test-c");
expect(result[0].result.lastRelease).toMatchObject({
gitHead: sha1,
gitTag: "msr-test-c@1.0.0",
version: "1.0.0",
});
expect(result[0].result.nextRelease).toMatchObject({
gitHead: sha2,
gitTag: "msr-test-c@1.1.0",
type: "minor",
version: "1.1.0",
});

// D.
expect(result[1].name).toBe("msr-test-d");
expect(result[1].result.nextRelease).toBeUndefined();

// ONLY three times.
expect(result[2]).toBe(undefined);
});

test("Changes in some packages (sequential-init)", async () => {
// Create Git repo.
const cwd = gitInit();
Expand Down

0 comments on commit 713046a

Please sign in to comment.