Skip to content

Commit

Permalink
Chore(inquirer): Drop cli-cursor dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Jun 25, 2024
1 parent 93e80e3 commit 595d755
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/inquirer/lib/prompts/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* `list` type prompt
*/

import ansiEscapes from 'ansi-escapes';
import chalk from 'chalk';
import cliCursor from 'cli-cursor';
import figures from '@inquirer/figures';
import { map, takeUntil } from 'rxjs';
import observe from '../utils/events.js';
Expand Down Expand Up @@ -69,7 +69,6 @@ export default class CheckboxPrompt extends Base {
events.iKey.pipe(takeUntil(validation.success)).forEach(this.onInverseKey.bind(this));

// Init the prompt
cliCursor.hide();
this.render();
this.firstRender = false;

Expand Down Expand Up @@ -136,6 +135,8 @@ export default class CheckboxPrompt extends Base {
bottomContent = chalk.red('>> ') + error;
}

message += ansiEscapes.cursorHide;

this.screen.render(message, bottomContent);
}

Expand All @@ -150,7 +151,6 @@ export default class CheckboxPrompt extends Base {
this.render();

this.screen.done();
cliCursor.show();
this.done(state.value);
}

Expand Down
5 changes: 2 additions & 3 deletions packages/inquirer/lib/prompts/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* `list` type prompt
*/

import ansiEscapes from 'ansi-escapes';
import chalk from 'chalk';
import figures from '@inquirer/figures';
import cliCursor from 'cli-cursor';
import runAsync from 'run-async';
import { flatMap, map, take, takeUntil } from 'rxjs';
import observe from '../utils/events.js';
Expand Down Expand Up @@ -66,7 +66,6 @@ export default class ListPrompt extends Base {
.forEach(this.onSubmit.bind(this));

// Init the prompt
cliCursor.hide();
this.render();

return this;
Expand Down Expand Up @@ -118,6 +117,7 @@ export default class ListPrompt extends Base {
'\n' + this.paginator.paginate(choicesStr, realIndexPosition, this.opt.pageSize);
}

message += ansiEscapes.cursorHide;
this.firstRender = false;

this.screen.render(message);
Expand All @@ -134,7 +134,6 @@ export default class ListPrompt extends Base {
this.render();

this.screen.done();
cliCursor.show();
this.done(value);
}

Expand Down
3 changes: 2 additions & 1 deletion packages/inquirer/lib/utils/screen-manager.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ansiEscapes from 'ansi-escapes';
import cliWidth from 'cli-width';
import wrapAnsi from 'wrap-ansi';
import stripAnsi from 'strip-ansi';
Expand Down Expand Up @@ -131,7 +132,7 @@ export default class ScreenManager {
done() {
this.rl.setPrompt('');
this.rl.output.unmute();
this.rl.output.write('\n');
this.rl.output.write(`\n${ansiEscapes.cursorShow}`);
}

releaseCursor() {
Expand Down
1 change: 0 additions & 1 deletion packages/inquirer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"@ljharb/through": "^2.3.13",
"ansi-escapes": "^4.3.2",
"chalk": "^5.3.0",
"cli-cursor": "^3.1.0",
"cli-width": "^4.1.0",
"external-editor": "^3.1.0",
"lodash": "^4.17.21",
Expand Down
1 change: 0 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4343,7 +4343,6 @@ __metadata:
"@ljharb/through": "npm:^2.3.13"
ansi-escapes: "npm:^4.3.2"
chalk: "npm:^5.3.0"
cli-cursor: "npm:^3.1.0"
cli-width: "npm:^4.1.0"
external-editor: "npm:^3.1.0"
lodash: "npm:^4.17.21"
Expand Down

0 comments on commit 595d755

Please sign in to comment.