@@ -14,7 +14,6 @@ export interface PromptOptions<Self extends Prompt> {
1414 render ( this : Omit < Self , 'prompt' > ) : string | undefined ;
1515 placeholder ?: string ;
1616 initialValue ?: any ;
17- defaultValue ?: string ;
1817 validate ?: ( ( value : any ) => string | Error | undefined ) | undefined ;
1918 input ?: Readable ;
2019 output ?: Writable ;
@@ -195,22 +194,22 @@ export default class Prompt {
195194 if ( char && ( char . toLowerCase ( ) === 'y' || char . toLowerCase ( ) === 'n' ) ) {
196195 this . emit ( 'confirm' , char . toLowerCase ( ) === 'y' ) ;
197196 }
198- if ( ( char === '\t' || key ?. name === 'return' ) && this . opts . placeholder ) {
197+ if ( char === '\t' && this . opts . placeholder ) {
199198 if ( ! this . value ) {
200- if ( this . opts . defaultValue ) {
201- this . value = this . opts . defaultValue ;
202- this . emit ( 'value' , this . value ) ;
203- } else {
204- this . rl ?. write ( this . opts . placeholder ) ;
205- this . emit ( 'value' , this . opts . placeholder ) ;
206- }
199+ this . rl ?. write ( this . opts . placeholder ) ;
200+ this . emit ( 'value' , this . opts . placeholder ) ;
207201 }
208202 }
209203 if ( char ) {
210204 this . emit ( 'key' , char . toLowerCase ( ) ) ;
211205 }
212206
213207 if ( key ?. name === 'return' ) {
208+ if ( ! this . value && this . opts . placeholder ) {
209+ this . rl ?. write ( this . opts . placeholder ) ;
210+ this . emit ( 'value' , this . opts . placeholder ) ;
211+ }
212+
214213 if ( this . opts . validate ) {
215214 const problem = this . opts . validate ( this . value ) ;
216215 if ( problem ) {
0 commit comments