Skip to content

Commit

Permalink
fix(package): Chain self from serialize() method for parity with refr…
Browse files Browse the repository at this point in the history
…esh()
  • Loading branch information
evocateur committed Dec 20, 2018
1 parent 284aa47 commit 98c812c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions core/package/__tests__/core-package.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ describe("Package", () => {
loadJsonFile.mockImplementationOnce(() => Promise.resolve({ name: "ignored", mutated: true }));

const pkg = factory({ name: "refresh" });
const result = await pkg.refresh();

await pkg.refresh();

expect(result).toBe(pkg);
// a package's name never changes
expect(pkg.name).toBe("refresh");
expect(pkg.get("mutated")).toBe(true);
Expand All @@ -226,9 +226,9 @@ describe("Package", () => {
writePkg.mockImplementation(() => Promise.resolve());

const pkg = factory({ name: "serialize-me" });
const result = await pkg.set("woo", "hoo").serialize();

await pkg.set("woo", "hoo").serialize();

expect(result).toBe(pkg);
expect(writePkg).toHaveBeenLastCalledWith(
pkg.manifestLocation,
expect.objectContaining({
Expand Down
2 changes: 1 addition & 1 deletion core/package/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class Package {
* @returns {Promise} resolves when write finished
*/
serialize() {
return writePkg(this.manifestLocation, this[PKG]);
return writePkg(this.manifestLocation, this[PKG]).then(() => this);
}

/**
Expand Down

0 comments on commit 98c812c

Please sign in to comment.