Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: possible fix for isTTY and GitBash #36

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
node_modules
.DS_Store
*.lock
*.log
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove .gitignore from this commit. The ignored files are not related to this project. Include them in your own global gitignore if needed.

coverage
.nyc_output
package-lock.json
lcov.info
.env
.pem
8 changes: 6 additions & 2 deletions lib/elements/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Prompt extends EventEmitter {
this.out = process.stdout;

const rl = readline.createInterface(this.in);
readline.emitKeypressEvents(this.in, this.rl);
readline.emitKeypressEvents(this.in, rl);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have to look into this. The second param to emitKeypressEvents is optional - do we even need it?

Also have to dig deeper into createInterface options like crlfDelay and terminal
https://nodejs.org/api/readline.html#readline_readline_createinterface_options


if (this.in.isTTY) {
this.in.setRawMode(true);
Expand All @@ -36,7 +36,11 @@ class Prompt extends EventEmitter {
const close = () => {
this.out.write(cursor.show);
this.in.removeListener('keypress', keypress);
this.in.setRawMode(false);
if (this.in.isTTY) {
this.in.setRawMode(false);
} else {
this.clear()
}
rl.close();
this.emit(this.aborted ? 'abort' : 'submit', this.value);
};
Expand Down