Skip to content

Commit

Permalink
create reference and create this.clear inside the IF when non TTY
Browse files Browse the repository at this point in the history
Signed-off-by: Charlike Mike Reagent <[email protected]>
  • Loading branch information
Charlike Mike Reagent committed Mar 3, 2018
1 parent daf27a3 commit 4fdaf6e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/elements/prompt.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const readline = require('readline');
const { action } = require('../util');
const { action, clear} = require('../util');
const EventEmitter = require('events');
const { beep, cursor, erase } = require('sisteransi');

Expand Down Expand Up @@ -39,8 +39,8 @@ class Prompt extends EventEmitter {
if (this.in.isTTY) {
this.in.setRawMode(false);
} else {
// we can't use `utils.clear()`, because it expect `prompt` string
this.out.write(erase.line + cursor.prevLine());
this.clear = clear(this.prompt)
this.out.write(this.clear);
}
rl.close();
this.emit(this.aborted ? 'abort' : 'submit', this.value);
Expand Down
6 changes: 3 additions & 3 deletions lib/elements/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ class TextPrompt extends Prompt {
}

render() {
const prompt = [
this.prompt = [
stl.symbol(this.done, this.aborted),
color.bold(this.msg),
stl.delimiter(this.done),
this.rendered
].join(' ');

this.out.write(this.clear + prompt);
this.out.write(this.clear + this.prompt);
this.out.write(cursor.move(-this.rendered.length + this.cursor));

this.clear = clear(prompt);
this.clear = clear(this.prompt);
}
}

Expand Down

0 comments on commit 4fdaf6e

Please sign in to comment.