[Pkg-javascript-commits] [node-cli-cursor] 01/04: Import Upstream version 1.0.2
Paolo Greppi
paolog-guest at moszumanska.debian.org
Fri Dec 23 11:19:11 UTC 2016
This is an automated email from the git hooks/post-receive script.
paolog-guest pushed a commit to branch master
in repository node-cli-cursor.
commit a25704f52f2b1eb165c14edfb9e834e3806ffd90
Author: Paolo Greppi <paolo.greppi at libpf.com>
Date: Fri Dec 23 10:51:45 2016 +0000
Import Upstream version 1.0.2
---
.editorconfig | 15 +++++++++++++
.gitattributes | 1 +
.gitignore | 1 +
.travis.yml | 5 +++++
index.js | 26 +++++++++++++++++++++++
license | 21 +++++++++++++++++++
package.json | 43 ++++++++++++++++++++++++++++++++++++++
readme.md | 40 +++++++++++++++++++++++++++++++++++
test.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9 files changed, 218 insertions(+)
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..8f9d77e
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,15 @@
+root = true
+
+[*]
+indent_style = tab
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[{package.json,*.yml}]
+indent_style = space
+indent_size = 2
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..aea1274
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,5 @@
+sudo: false
+language: node_js
+node_js:
+ - 'stable'
+ - '0.12'
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..d31d46b
--- /dev/null
+++ b/index.js
@@ -0,0 +1,26 @@
+'use strict';
+var restoreCursor = require('restore-cursor');
+var hidden = false;
+
+exports.show = function () {
+ hidden = false;
+ process.stdout.write('\u001b[?25h');
+};
+
+exports.hide = function () {
+ restoreCursor();
+ hidden = true;
+ process.stdout.write('\u001b[?25l');
+};
+
+exports.toggle = function (force) {
+ if (force !== undefined) {
+ hidden = force;
+ }
+
+ if (hidden) {
+ exports.show();
+ } else {
+ exports.hide();
+ }
+};
diff --git a/license b/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus at gmail.com> (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.
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..8297284
--- /dev/null
+++ b/package.json
@@ -0,0 +1,43 @@
+{
+ "name": "cli-cursor",
+ "version": "1.0.2",
+ "description": "Toggle the CLI cursor",
+ "license": "MIT",
+ "repository": "sindresorhus/cli-cursor",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus at gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "cli",
+ "cursor",
+ "ansi",
+ "toggle",
+ "display",
+ "show",
+ "hide",
+ "term",
+ "terminal",
+ "console",
+ "tty",
+ "shell",
+ "command-line"
+ ],
+ "dependencies": {
+ "restore-cursor": "^1.0.1"
+ },
+ "devDependencies": {
+ "ava": "*",
+ "xo": "*"
+ }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..8f64582
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,40 @@
+# cli-cursor [![Build Status](https://travis-ci.org/sindresorhus/cli-cursor.svg?branch=master)](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 --save cli-cursor
+```
+
+
+## Usage
+
+```js
+const cliCursor = require('cli-cursor');
+
+cliCursor.hide();
+
+const unicornsAreAwesome = true;
+cliCursor.toggle(unicornsAreAwesome);
+```
+
+
+## API
+
+### .show()
+
+### .hide()
+
+### .toggle(force)
+
+`force` is useful to show or hide the cursor based an a boolean.
+
+
+## License
+
+MIT © [Sindre Sorhus](http://sindresorhus.com)
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..6ae456e
--- /dev/null
+++ b/test.js
@@ -0,0 +1,66 @@
+import childProcess from 'child_process';
+import test from 'ava';
+import cliCursor from './';
+
+const write = process.stdout.write;
+const SHOW = '\u001b[?25h';
+const HIDE = '\u001b[?25l';
+
+function getStdout(fn) {
+ let ret = '';
+
+ process.stdout.setEncoding('utf8');
+ process.stdout.write = str => {
+ ret += str;
+ };
+
+ fn();
+ process.stdout.write = write;
+ return ret;
+}
+
+test('show', t => {
+ t.is(getStdout(cliCursor.show), SHOW);
+ t.end();
+});
+
+test('hide', t => {
+ t.is(getStdout(cliCursor.hide), HIDE);
+ t.end();
+});
+
+test('toggle', t => {
+ cliCursor.hide();
+ t.is(getStdout(cliCursor.toggle), SHOW);
+ t.end();
+});
+
+test('toggle 2', t => {
+ cliCursor.show();
+ t.is(getStdout(cliCursor.toggle), HIDE);
+ t.end();
+});
+
+test('toggle force', t => {
+ cliCursor.show();
+ t.is(getStdout(cliCursor.toggle.bind(null, true)), SHOW);
+ t.end();
+});
+
+test('toggle force 2', t => {
+ cliCursor.hide();
+ t.is(getStdout(cliCursor.toggle.bind(null, true)), SHOW);
+ t.end();
+});
+
+test('toggle force 3', t => {
+ cliCursor.show();
+ t.is(getStdout(cliCursor.toggle.bind(null, false)), HIDE);
+ t.end();
+});
+
+// used to fail, see sindresorhus/log-update#2
+test('require', t => {
+ t.is(childProcess.execSync('node index.js', {encoding: 'utf8'}), '');
+ t.end();
+});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-cli-cursor.git
More information about the Pkg-javascript-commits
mailing list