Skip to content

Commit

Permalink
fix: empty prompts should now bypass properly
Browse files Browse the repository at this point in the history
Co-authored-by: Axel Hecht <axel@pike.org>
  • Loading branch information
crutchcorn and Pike committed Dec 9, 2021
1 parent 3fe7308 commit 1969d45
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/bypass.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function combineBypassData(generator, bypassArr, plopArgV) {
process.exit(1);
}
namedBypassArr = promptNames.map((name) =>
plopArgV[name] ? plopArgV[name] : undefined
plopArgV[name] !== undefined ? plopArgV[name] : undefined
);
}

Expand Down
6 changes: 0 additions & 6 deletions tests/examples/prompt-only/plopfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ export default function (plop) {
type: "input",
name: "name",
message: "What is your name?",
validate: function (value) {
if (/.+/.test(value)) {
return true;
}
return "name is required";
},
},
{
type: "checkbox",
Expand Down
9 changes: 9 additions & 0 deletions tests/input-processing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,13 @@ test("Should bypass prompt by name", async () => {
expect(await findByText("What pizza toppings do you like?")).toBeTruthy();
});

test("Should allow for empty string bypassing", async () => {
const { queryByText, findByText } = await renderPlop(["--", "--name", `""`], {
cwd: resolve(__dirname, "./examples/prompt-only"),
});

expect(await queryByText("What is your name?")).toBeFalsy();
expect(await findByText("What pizza toppings do you like?")).toBeTruthy();
});

test.todo("Dynamic actions");

0 comments on commit 1969d45

Please sign in to comment.