Skip to content

Commit

Permalink
Revert setRawMode on --watch quit (fixes #5028) (#5029)
Browse files Browse the repository at this point in the history
* Revert setRawMode on --watch ctrl-c (#5028)

* Disable stdin raw mode in watch quit plugin (#5028)

* Update changelog
  • Loading branch information
andyearnshaw authored and cpojer committed Feb 14, 2018
1 parent 84e9789 commit 4ca959b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Fixes

* `[jest-cli]` Fix inability to quit watch mode while debugger is still attached
([#5029](https://github.com/facebook/jest/pull/5029))
* `[jest-haste-map]` Properly handle platform-specific file deletions
([#5534](https://github.com/facebook/jest/pull/5534))

Expand Down
3 changes: 3 additions & 0 deletions packages/jest-cli/src/plugins/quit.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import WatchPlugin from '../watch_plugin';

class QuitPlugin extends WatchPlugin {
async showPrompt() {
if (typeof this._stdin.setRawMode === 'function') {
this._stdin.setRawMode(false);
}
this._stdout.write('\n');
process.exit(0);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/jest-cli/src/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ export default function watch(

const onKeypress = (key: string) => {
if (key === KEYS.CONTROL_C || key === KEYS.CONTROL_D) {
if (typeof stdin.setRawMode === 'function') {
stdin.setRawMode(false);
}
outputStream.write('\n');
exit(0);
return;
Expand Down

0 comments on commit 4ca959b

Please sign in to comment.