Skip to content

Commit

Permalink
refactor: Migrate to unambiguous promptConfirmation()
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed Dec 10, 2020
1 parent 5d05d95 commit 3c67f15
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions commands/clean/__tests__/clean-command.test.js
Expand Up @@ -26,15 +26,15 @@ describe("CleanCommand", () => {
// .mockResolvedValue() doesn't work when you want to reject it later
rimrafDir.mockImplementation(() => Promise.resolve());

PromptUtilities.confirm.mockResolvedValue(true);
PromptUtilities.promptConfirmation.mockResolvedValue(true);

describe("basic tests", () => {
it("should rm -rf the node_modules", async () => {
const testDir = await initFixture("basic");

await lernaClean(testDir)();

expect(PromptUtilities.confirm).toHaveBeenCalled();
expect(PromptUtilities.promptConfirmation).toHaveBeenCalled();
expect(removedDirectories(testDir)).toEqual([
"packages/package-1/node_modules",
"packages/package-2/node_modules",
Expand All @@ -45,7 +45,7 @@ describe("CleanCommand", () => {
it("exits early when confirmation is rejected", async () => {
const testDir = await initFixture("basic");

PromptUtilities.confirm.mockResolvedValueOnce(false);
PromptUtilities.promptConfirmation.mockResolvedValueOnce(false);

await lernaClean(testDir)();

Expand All @@ -57,7 +57,7 @@ describe("CleanCommand", () => {

await lernaClean(testDir)("--yes");

expect(PromptUtilities.confirm).not.toHaveBeenCalled();
expect(PromptUtilities.promptConfirmation).not.toHaveBeenCalled();
});

it("should only clean scoped packages", async () => {
Expand Down
2 changes: 1 addition & 1 deletion commands/clean/index.js
Expand Up @@ -39,7 +39,7 @@ class CleanCommand extends Command {
this.directoriesToDelete.map((dir) => path.relative(this.project.rootPath, dir)).join("\n")
);

return PromptUtilities.confirm("Proceed?");
return PromptUtilities.promptConfirmation("Proceed?");
});
}

Expand Down
6 changes: 3 additions & 3 deletions commands/import/__tests__/import-command.test.js
Expand Up @@ -25,7 +25,7 @@ const lastCommitInDir = (cwd) =>
execa("git", ["log", "-1", "--format=%s"], { cwd }).then((result) => result.stdout);

describe("ImportCommand", () => {
PromptUtilities.confirm.mockResolvedValue(true);
PromptUtilities.promptConfirmation.mockResolvedValue(true);

describe("import", () => {
const initBasicFixtures = async () => {
Expand Down Expand Up @@ -178,7 +178,7 @@ describe("ImportCommand", () => {
it("exits early when confirmation is rejected", async () => {
const [testDir, externalDir] = await initBasicFixtures();

PromptUtilities.confirm.mockResolvedValueOnce(false);
PromptUtilities.promptConfirmation.mockResolvedValueOnce(false);

await lernaImport(testDir)(externalDir);

Expand Down Expand Up @@ -222,7 +222,7 @@ describe("ImportCommand", () => {
const [testDir, externalDir] = await initBasicFixtures();
await lernaImport(testDir)(externalDir, "--yes");

expect(PromptUtilities.confirm).not.toHaveBeenCalled();
expect(PromptUtilities.promptConfirmation).not.toHaveBeenCalled();
});

it("errors without an argument", async () => {
Expand Down
2 changes: 1 addition & 1 deletion commands/import/index.js
Expand Up @@ -114,7 +114,7 @@ class ImportCommand extends Command {
return true;
}

return PromptUtilities.confirm("Are you sure you want to import these commits onto the current branch?");
return PromptUtilities.promptConfirmation("Are you sure you want to import these commits onto the current branch?");
}

getPackageDirectories() {
Expand Down
2 changes: 1 addition & 1 deletion commands/publish/__tests__/publish-canary.test.js
Expand Up @@ -75,7 +75,7 @@ test("publish --canary", async () => {
);
await lernaPublish(cwd)("--canary");

expect(PromptUtilities.confirm).toHaveBeenLastCalledWith(
expect(PromptUtilities.promptConfirmation).toHaveBeenLastCalledWith(
"Are you sure you want to publish these packages?"
);
expect(npmPublish.registry).toMatchInlineSnapshot(`
Expand Down
2 changes: 1 addition & 1 deletion commands/publish/__tests__/publish-command.test.js
Expand Up @@ -97,7 +97,7 @@ describe("PublishCommand", () => {

await lernaPublish(testDir)();

expect(PromptUtilities.confirm).toHaveBeenLastCalledWith(
expect(PromptUtilities.promptConfirmation).toHaveBeenLastCalledWith(
"Are you sure you want to publish these packages?"
);
expect(packDirectory.registry).toMatchInlineSnapshot(`
Expand Down
2 changes: 1 addition & 1 deletion commands/publish/__tests__/publish-from-git.test.js
Expand Up @@ -39,7 +39,7 @@ describe("publish from-git", () => {
// called from chained describeRef()
expect(throwIfUncommitted).toHaveBeenCalled();

expect(PromptUtilities.confirm).toHaveBeenLastCalledWith(
expect(PromptUtilities.promptConfirmation).toHaveBeenLastCalledWith(
"Are you sure you want to publish these packages?"
);
expect(output.logged()).toMatch("Found 4 packages to publish:");
Expand Down
2 changes: 1 addition & 1 deletion commands/publish/__tests__/publish-from-package.test.js
Expand Up @@ -41,7 +41,7 @@ describe("publish from-package", () => {

await lernaPublish(cwd)("from-package");

expect(PromptUtilities.confirm).toHaveBeenLastCalledWith(
expect(PromptUtilities.promptConfirmation).toHaveBeenLastCalledWith(
"Are you sure you want to publish these packages?"
);
expect(output.logged()).toMatch("Found 2 packages to publish:");
Expand Down
2 changes: 1 addition & 1 deletion commands/publish/index.js
Expand Up @@ -426,7 +426,7 @@ class PublishCommand extends Command {
return true;
}

return PromptUtilities.confirm("Are you sure you want to publish these packages?");
return PromptUtilities.promptConfirmation("Are you sure you want to publish these packages?");
}

prepareLicenseActions() {
Expand Down
8 changes: 4 additions & 4 deletions commands/version/__tests__/version-command.test.js
Expand Up @@ -57,7 +57,7 @@ describe("VersionCommand", () => {
expect(checkWorkingTree).toHaveBeenCalled();

expect(PromptUtilities.promptSelectOne.mock.calls).toMatchSnapshot("prompt");
expect(PromptUtilities.confirm).toHaveBeenLastCalledWith(
expect(PromptUtilities.promptConfirmation).toHaveBeenLastCalledWith(
"Are you sure you want to create these versions?"
);

Expand Down Expand Up @@ -181,7 +181,7 @@ describe("VersionCommand", () => {
const testDir = await initFixture("independent");
await lernaVersion(testDir)(); // --independent is only valid in InitCommand

expect(PromptUtilities.confirm).toHaveBeenCalled();
expect(PromptUtilities.promptConfirmation).toHaveBeenCalled();

expect(writePkg.updatedManifest("package-1")).toMatchSnapshot("gitHead");

Expand Down Expand Up @@ -455,7 +455,7 @@ describe("VersionCommand", () => {
await lernaVersion(testDir)("--yes", "patch");

expect(PromptUtilities.promptSelectOne).not.toHaveBeenCalled();
expect(PromptUtilities.confirm).not.toHaveBeenCalled();
expect(PromptUtilities.promptConfirmation).not.toHaveBeenCalled();

const message = await getCommitMessage(testDir);
expect(message).toBe("v1.0.1");
Expand Down Expand Up @@ -749,7 +749,7 @@ describe("VersionCommand", () => {
await lernaVersion(testDir)("--include-merged-tags", "--yes", "patch");

expect(PromptUtilities.promptSelectOne).not.toHaveBeenCalled();
expect(PromptUtilities.confirm).not.toHaveBeenCalled();
expect(PromptUtilities.promptConfirmation).not.toHaveBeenCalled();

const message = await getCommitMessage(testDir);
expect(message).toBe("v1.0.1");
Expand Down
2 changes: 1 addition & 1 deletion commands/version/index.js
Expand Up @@ -488,7 +488,7 @@ class VersionCommand extends Command {
? "Are you sure you want to publish these packages?"
: "Are you sure you want to create these versions?";

return PromptUtilities.confirm(message);
return PromptUtilities.promptConfirmation(message);
}

updatePackageVersions() {
Expand Down

0 comments on commit 3c67f15

Please sign in to comment.