Skip to content

Commit

Permalink
fix(publish): Use package version as fallback for independent canary …
Browse files Browse the repository at this point in the history
…bump

Fixes #1614
  • Loading branch information
evocateur committed Aug 28, 2018
1 parent 02a2380 commit 989a3b5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
25 changes: 25 additions & 0 deletions commands/publish/__tests__/publish-canary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,31 @@ Object {
`);
});

test("publish --canary addresses unpublished package", async () => {
const cwd = await initTaggedFixture("independent");

await setupChanges(
cwd,
[
"packages/package-6/package.json",
JSON.stringify({
name: "package-6",
// npm init starts at 1.0.0,
// but an unpublished 1.0.0 should be 1.0.0-alpha.0, n'est-ce pas?
version: "0.1.0",
}),
],
["packages/package-6/new-kids.js", "on the block"]
);
await lernaPublish(cwd)("--canary", "premajor");

expect(writePkg.updatedVersions()).toMatchInlineSnapshot(`
Object {
"package-6": 1.0.0-alpha.0+SHA,
}
`);
});

describe("publish --canary differential", () => {
test("source", async () => {
const cwd = await initTaggedFixture("snake-graph");
Expand Down
5 changes: 4 additions & 1 deletion commands/publish/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ class PublishCommand extends Command {
match: `${pkg.name}@*`,
cwd: this.execOpts.cwd,
})
.then(makeVersion)
.then(({ lastVersion = pkg.version, refCount = 1, sha }) =>
// an unpublished package will have no reachable git tag
makeVersion({ lastVersion, refCount, sha })
)
.then(version => [pkg.name, version])
).then(updatesVersions => ({
updates,
Expand Down

0 comments on commit 989a3b5

Please sign in to comment.