Skip to content

Commit

Permalink
fix(publish): Canary releases without previous tags should not explode
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed May 12, 2020
1 parent 6c4ee52 commit c9eb590
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
28 changes: 28 additions & 0 deletions commands/publish/__tests__/publish-canary.test.js
Expand Up @@ -373,3 +373,31 @@ test("publish --canary --include-merged-tags calls git describe correctly", asyn
expect.objectContaining({ cwd })
);
});

test("publish --canary without _any_ tags", async () => {
const cwd = await initFixture("normal");
await lernaPublish(cwd)("--canary");

expect(writePkg.updatedVersions()).toMatchInlineSnapshot(`
Object {
"package-1": 1.0.1-alpha.0+SHA,
"package-2": 1.0.1-alpha.0+SHA,
"package-3": 1.0.1-alpha.0+SHA,
"package-4": 1.0.1-alpha.0+SHA,
}
`);
});

test("publish --canary without _any_ tags (independent)", async () => {
const cwd = await initFixture("independent");
await lernaPublish(cwd)("--canary");

expect(writePkg.updatedVersions()).toMatchInlineSnapshot(`
Object {
"package-1": 1.0.1-alpha.0+SHA,
"package-2": 2.0.1-alpha.0+SHA,
"package-3": 3.0.1-alpha.0+SHA,
"package-4": 4.0.1-alpha.0+SHA,
}
`);
});
5 changes: 4 additions & 1 deletion commands/publish/index.js
Expand Up @@ -390,7 +390,10 @@ class PublishCommand extends Command {
},
includeMergedTags
)
.then(makeVersion)
.then(({ lastVersion = this.project.version, refCount, sha }) =>
// a repo with no tags should default to whatever lerna.json claims
makeVersion({ lastVersion, refCount, sha })
)
.then(version => updates.map(({ pkg }) => [pkg.name, version]))
.then(updatesVersions => ({
updates,
Expand Down

0 comments on commit c9eb590

Please sign in to comment.