您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839
  1. import process from 'node:process';
  2. import restoreCursor from 'restore-cursor';
  3. let isHidden = false;
  4. const cliCursor = {};
  5. cliCursor.show = (writableStream = process.stderr) => {
  6. if (!writableStream.isTTY) {
  7. return;
  8. }
  9. isHidden = false;
  10. writableStream.write('\u001B[?25h');
  11. };
  12. cliCursor.hide = (writableStream = process.stderr) => {
  13. if (!writableStream.isTTY) {
  14. return;
  15. }
  16. restoreCursor();
  17. isHidden = true;
  18. writableStream.write('\u001B[?25l');
  19. };
  20. cliCursor.toggle = (force, writableStream) => {
  21. if (force !== undefined) {
  22. isHidden = force;
  23. }
  24. if (isHidden) {
  25. cliCursor.show(writableStream);
  26. } else {
  27. cliCursor.hide(writableStream);
  28. }
  29. };
  30. export default cliCursor;