Skip to content

Commit 41fe0c8

Browse files
Enhance stdin handling in create-plugma by mocking isTTY and setRawMode for improved compatibility with non-interactive project creation, while ensuring original functionality is restored after use.
1 parent c682b07 commit 41fe0c8

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

packages/create-plugma/src/create.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,12 +577,21 @@ async function browseAndSelectTemplate(
577577

578578
// Temporarily override stdin to appear as a TTY (for askeroo/Ink compatibility)
579579
const originalIsTTY = process.stdin.isTTY;
580+
const originalSetRawMode = process.stdin.setRawMode;
581+
582+
// Mock isTTY
580583
Object.defineProperty(process.stdin, 'isTTY', {
581584
get() {
582585
return true;
583586
},
584587
});
585588

589+
// Mock setRawMode
590+
process.stdin.setRawMode = (mode: boolean) => {
591+
// No-op in non-interactive mode
592+
return process.stdin;
593+
};
594+
586595
try {
587596
// Still need ask() for runtime context, but we'll immediately run the creation
588597
await ask(async () => {
@@ -613,6 +622,9 @@ async function browseAndSelectTemplate(
613622
return originalIsTTY;
614623
},
615624
});
625+
626+
// Restore original setRawMode
627+
process.stdin.setRawMode = originalSetRawMode;
616628
}
617629

618630
return;

0 commit comments

Comments
 (0)