Skip to content

Commit 1969d45

Browse files
crutchcornPike
andcommitted
fix: empty prompts should now bypass properly
Co-authored-by: Axel Hecht <[email protected]>
1 parent 3fe7308 commit 1969d45

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/bypass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function combineBypassData(generator, bypassArr, plopArgV) {
5252
process.exit(1);
5353
}
5454
namedBypassArr = promptNames.map((name) =>
55-
plopArgV[name] ? plopArgV[name] : undefined
55+
plopArgV[name] !== undefined ? plopArgV[name] : undefined
5656
);
5757
}
5858

tests/examples/prompt-only/plopfile.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ export default function (plop) {
66
type: "input",
77
name: "name",
88
message: "What is your name?",
9-
validate: function (value) {
10-
if (/.+/.test(value)) {
11-
return true;
12-
}
13-
return "name is required";
14-
},
159
},
1610
{
1711
type: "checkbox",

tests/input-processing.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,13 @@ test("Should bypass prompt by name", async () => {
9494
expect(await findByText("What pizza toppings do you like?")).toBeTruthy();
9595
});
9696

97+
test("Should allow for empty string bypassing", async () => {
98+
const { queryByText, findByText } = await renderPlop(["--", "--name", `""`], {
99+
cwd: resolve(__dirname, "./examples/prompt-only"),
100+
});
101+
102+
expect(await queryByText("What is your name?")).toBeFalsy();
103+
expect(await findByText("What pizza toppings do you like?")).toBeTruthy();
104+
});
105+
97106
test.todo("Dynamic actions");

0 commit comments

Comments
 (0)