pax_global_header 0000666 0000000 0000000 00000000064 13477756560 0014536 g ustar 00root root 0000000 0000000 52 comment=49edacfb841a9dac691972c2aa5d40dba8e0b56b
cli-cursor-3.1.0/ 0000775 0000000 0000000 00000000000 13477756560 0013621 5 ustar 00root root 0000000 0000000 cli-cursor-3.1.0/.editorconfig 0000664 0000000 0000000 00000000257 13477756560 0016302 0 ustar 00root root 0000000 0000000 root = true
[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.yml]
indent_style = space
indent_size = 2
cli-cursor-3.1.0/.gitattributes 0000664 0000000 0000000 00000000023 13477756560 0016507 0 ustar 00root root 0000000 0000000 * text=auto eol=lf
cli-cursor-3.1.0/.github/ 0000775 0000000 0000000 00000000000 13477756560 0015161 5 ustar 00root root 0000000 0000000 cli-cursor-3.1.0/.github/funding.yml 0000664 0000000 0000000 00000000164 13477756560 0017337 0 ustar 00root root 0000000 0000000 github: sindresorhus
open_collective: sindresorhus
tidelift: npm/cli-cursor
custom: https://sindresorhus.com/donate
cli-cursor-3.1.0/.github/security.md 0000664 0000000 0000000 00000000263 13477756560 0017353 0 ustar 00root root 0000000 0000000 # Security Policy
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
cli-cursor-3.1.0/.gitignore 0000664 0000000 0000000 00000000027 13477756560 0015610 0 ustar 00root root 0000000 0000000 node_modules
yarn.lock
cli-cursor-3.1.0/.npmrc 0000664 0000000 0000000 00000000023 13477756560 0014734 0 ustar 00root root 0000000 0000000 package-lock=false
cli-cursor-3.1.0/.travis.yml 0000664 0000000 0000000 00000000065 13477756560 0015733 0 ustar 00root root 0000000 0000000 language: node_js
node_js:
- '12'
- '10'
- '8'
cli-cursor-3.1.0/index.d.ts 0000664 0000000 0000000 00000001434 13477756560 0015524 0 ustar 00root root 0000000 0000000 ///
/**
Show cursor.
@param stream - Default: `process.stderr`.
@example
```
import * as cliCursor from 'cli-cursor';
cliCursor.show();
```
*/
export function show(stream?: NodeJS.WritableStream): void;
/**
Hide cursor.
@param stream - Default: `process.stderr`.
@example
```
import * as cliCursor from 'cli-cursor';
cliCursor.hide();
```
*/
export function hide(stream?: NodeJS.WritableStream): void;
/**
Toggle cursor visibility.
@param force - Is useful to show or hide the cursor based on a boolean.
@param stream - Default: `process.stderr`.
@example
```
import * as cliCursor from 'cli-cursor';
const unicornsAreAwesome = true;
cliCursor.toggle(unicornsAreAwesome);
```
*/
export function toggle(force?: boolean, stream?: NodeJS.WritableStream): void;
cli-cursor-3.1.0/index.js 0000664 0000000 0000000 00000001151 13477756560 0015264 0 ustar 00root root 0000000 0000000 'use strict';
const restoreCursor = require('restore-cursor');
let isHidden = false;
exports.show = (writableStream = process.stderr) => {
if (!writableStream.isTTY) {
return;
}
isHidden = false;
writableStream.write('\u001B[?25h');
};
exports.hide = (writableStream = process.stderr) => {
if (!writableStream.isTTY) {
return;
}
restoreCursor();
isHidden = true;
writableStream.write('\u001B[?25l');
};
exports.toggle = (force, writableStream) => {
if (force !== undefined) {
isHidden = force;
}
if (isHidden) {
exports.show(writableStream);
} else {
exports.hide(writableStream);
}
};
cli-cursor-3.1.0/index.test-d.ts 0000664 0000000 0000000 00000000335 13477756560 0016500 0 ustar 00root root 0000000 0000000 import * as cliCursor from '.';
cliCursor.hide();
cliCursor.hide(process.stderr);
cliCursor.show();
cliCursor.show(process.stderr);
cliCursor.toggle();
cliCursor.toggle(false);
cliCursor.toggle(false, process.stderr);
cli-cursor-3.1.0/license 0000664 0000000 0000000 00000002125 13477756560 0015166 0 ustar 00root root 0000000 0000000 MIT License
Copyright (c) Sindre Sorhus (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
cli-cursor-3.1.0/package.json 0000664 0000000 0000000 00000001313 13477756560 0016105 0 ustar 00root root 0000000 0000000 {
"name": "cli-cursor",
"version": "3.1.0",
"description": "Toggle the CLI cursor",
"license": "MIT",
"repository": "sindresorhus/cli-cursor",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"cli",
"cursor",
"ansi",
"toggle",
"display",
"show",
"hide",
"term",
"terminal",
"console",
"tty",
"shell",
"command-line"
],
"dependencies": {
"restore-cursor": "^3.1.0"
},
"devDependencies": {
"@types/node": "^12.0.7",
"ava": "^2.1.0",
"tsd": "^0.7.2",
"xo": "^0.24.0"
}
}
cli-cursor-3.1.0/readme.md 0000664 0000000 0000000 00000002157 13477756560 0015405 0 ustar 00root root 0000000 0000000 # cli-cursor [](https://travis-ci.org/sindresorhus/cli-cursor)
> Toggle the CLI cursor
The cursor is [gracefully restored](https://github.com/sindresorhus/restore-cursor) if the process exits.
## Install
```
$ npm install cli-cursor
```
## Usage
```js
const cliCursor = require('cli-cursor');
cliCursor.hide();
const unicornsAreAwesome = true;
cliCursor.toggle(unicornsAreAwesome);
```
## API
### .show(stream?)
### .hide(stream?)
### .toggle(force?, stream?)
#### force
Useful for showing or hiding the cursor based on a boolean.
#### stream
Type: `stream.Writable`
Default: `process.stderr`
---
cli-cursor-3.1.0/test.js 0000664 0000000 0000000 00000002266 13477756560 0015144 0 ustar 00root root 0000000 0000000 import childProcess from 'child_process';
import test from 'ava';
import cliCursor from '.';
const {stderr: {write}} = process;
const SHOW = '\u001B[?25h';
const HIDE = '\u001B[?25l';
process.stderr.isTTY = true;
function getStderr(fn) {
let result = '';
process.stderr.setEncoding('utf8');
process.stderr.write = string => {
result += string;
};
fn();
process.stderr.write = write;
return result;
}
test('show', t => {
t.is(getStderr(cliCursor.show), SHOW);
});
test('hide', t => {
t.is(getStderr(cliCursor.hide), HIDE);
});
test('toggle', t => {
cliCursor.hide();
t.is(getStderr(cliCursor.toggle), SHOW);
});
test('toggle 2', t => {
cliCursor.show();
t.is(getStderr(cliCursor.toggle), HIDE);
});
test('toggle force', t => {
cliCursor.show();
t.is(getStderr(cliCursor.toggle.bind(null, true)), SHOW);
});
test('toggle force 2', t => {
cliCursor.hide();
t.is(getStderr(cliCursor.toggle.bind(null, true)), SHOW);
});
test('toggle force 3', t => {
cliCursor.show();
t.is(getStderr(cliCursor.toggle.bind(null, false)), HIDE);
});
// Used to fail, see sindresorhus/log-update#2
test('require', t => {
t.is(childProcess.execSync('node index.js', {encoding: 'utf8'}), '');
});