[Pkg-javascript-commits] [node-ansi-escapes] 01/03: New upstream version 2.0.0

Paolo Greppi paolog-guest at moszumanska.debian.org
Tue May 30 15:29:51 UTC 2017


This is an automated email from the git hooks/post-receive script.

paolog-guest pushed a commit to branch master
in repository node-ansi-escapes.

commit ccc874fbe99dc0e2d336cae4999c59c5aab48528
Author: Paolo Greppi <paolo.greppi at libpf.com>
Date:   Tue May 30 17:18:09 2017 +0200

    New upstream version 2.0.0
---
 .gitattributes |  1 +
 .travis.yml    |  4 +---
 example.js     |  4 ++--
 index.js       | 60 +++++++++++++++++++++++++---------------------------------
 package.json   |  4 ++--
 readme.md      |  6 +++---
 test.js        |  4 ++--
 7 files changed, 37 insertions(+), 46 deletions(-)

diff --git a/.gitattributes b/.gitattributes
index 176a458..391f0a4 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1 +1,2 @@
 * text=auto
+*.js text eol=lf
diff --git a/.travis.yml b/.travis.yml
index ab2fee2..97519af 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,4 @@
 language: node_js
 node_js:
-  - '5'
+  - '6'
   - '4'
-  - '0.12'
-  - '0.10'
diff --git a/example.js b/example.js
index b282959..df4dac0 100644
--- a/example.js
+++ b/example.js
@@ -1,4 +1,4 @@
-var fs = require('fs');
-var ansiEscapes = require('./');
+const fs = require('fs');
+const ansiEscapes = require('.');
 
 console.log(ansiEscapes.image(fs.readFileSync('fixture.jpg'), {width: 15}));
diff --git a/index.js b/index.js
index 7f61fc3..ebd413b 100644
--- a/index.js
+++ b/index.js
@@ -1,6 +1,7 @@
 'use strict';
-var ESC = '\u001b[';
-var x = module.exports;
+const x = module.exports;
+const ESC = '\u001B[';
+const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';
 
 x.cursorTo = function (x, y) {
 	if (arguments.length === 0) {
@@ -14,8 +15,8 @@ x.cursorTo = function (x, y) {
 	return ESC + (y + 1) + ';' + (x + 1) + 'H';
 };
 
-x.cursorMove = function (x, y) {
-	var ret = '';
+x.cursorMove = (x, y) => {
+	let ret = '';
 
 	if (x < 0) {
 		ret += ESC + (-x) + 'D';
@@ -32,36 +33,29 @@ x.cursorMove = function (x, y) {
 	return ret;
 };
 
-x.cursorUp = function (count) {
-	return ESC + (typeof count === 'number' ? count : 1) + 'A';
-};
-
-x.cursorDown = function (count) {
-	return ESC + (typeof count === 'number' ? count : 1) + 'B';
-};
-
-x.cursorForward = function (count) {
-	return ESC + (typeof count === 'number' ? count : 1) + 'C';
-};
+x.cursorUp = count => ESC + (typeof count === 'number' ? count : 1) + 'A';
+x.cursorDown = count => ESC + (typeof count === 'number' ? count : 1) + 'B';
+x.cursorForward = count => ESC + (typeof count === 'number' ? count : 1) + 'C';
+x.cursorBackward = count => ESC + (typeof count === 'number' ? count : 1) + 'D';
 
-x.cursorBackward = function (count) {
-	return ESC + (typeof count === 'number' ? count : 1) + 'D';
-};
-
-x.cursorLeft = ESC + '1000D';
-x.cursorSavePosition = ESC + 's';
-x.cursorRestorePosition = ESC + 'u';
+x.cursorLeft = ESC + 'G';
+x.cursorSavePosition = ESC + (isTerminalApp ? '7' : 's');
+x.cursorRestorePosition = ESC + (isTerminalApp ? '8' : 'u');
 x.cursorGetPosition = ESC + '6n';
 x.cursorNextLine = ESC + 'E';
 x.cursorPrevLine = ESC + 'F';
 x.cursorHide = ESC + '?25l';
 x.cursorShow = ESC + '?25h';
 
-x.eraseLines = function (count) {
-	var clear = '';
+x.eraseLines = count => {
+	let clear = '';
 
-	for (var i = 0; i < count; i++) {
-		clear += x.cursorLeft + x.eraseEndLine + (i < count - 1 ? x.cursorUp() : '');
+	for (let i = 0; i < count; i++) {
+		clear += x.eraseLine + (i < count - 1 ? x.cursorUp() : '');
+	}
+
+	if (count) {
+		clear += x.cursorLeft;
 	}
 
 	return clear;
@@ -76,20 +70,20 @@ x.eraseScreen = ESC + '2J';
 x.scrollUp = ESC + 'S';
 x.scrollDown = ESC + 'T';
 
-x.clearScreen = '\u001bc';
+x.clearScreen = '\u001Bc';
 x.beep = '\u0007';
 
-x.image = function (buf, opts) {
+x.image = (buf, opts) => {
 	opts = opts || {};
 
-	var ret = '\u001b]1337;File=inline=1';
+	let ret = '\u001B]1337;File=inline=1';
 
 	if (opts.width) {
-		ret += ';width=' + opts.width;
+		ret += `;width=${opts.width}`;
 	}
 
 	if (opts.height) {
-		ret += ';height=' + opts.height;
+		ret += `;height=${opts.height}`;
 	}
 
 	if (opts.preserveAspectRatio === false) {
@@ -101,6 +95,4 @@ x.image = function (buf, opts) {
 
 x.iTerm = {};
 
-x.iTerm.setCwd = function (cwd) {
-	return '\u001b]50;CurrentDir=' + (cwd || process.cwd()) + '\u0007';
-};
+x.iTerm.setCwd = cwd => '\u001B]50;CurrentDir=' + (cwd || process.cwd()) + '\u0007';
diff --git a/package.json b/package.json
index ed1a4ea..fa9df55 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "ansi-escapes",
-  "version": "1.4.0",
+  "version": "2.0.0",
   "description": "ANSI escape codes for manipulating the terminal",
   "license": "MIT",
   "repository": "sindresorhus/ansi-escapes",
@@ -10,7 +10,7 @@
     "url": "sindresorhus.com"
   },
   "engines": {
-    "node": ">=0.10.0"
+    "node": ">=4"
   },
   "scripts": {
     "test": "xo && ava"
diff --git a/readme.md b/readme.md
index c1254e9..21188c9 100644
--- a/readme.md
+++ b/readme.md
@@ -15,9 +15,9 @@ $ npm install --save ansi-escapes
 ```js
 const ansiEscapes = require('ansi-escapes');
 
-// moves the cursor two rows up and to the left
+// Moves the cursor two rows up and to the left
 process.stdout.write(ansiEscapes.cursorUp(2) + ansiEscapes.cursorLeft);
-//=> '\u001b[2A\u001b[1000D'
+//=> '\u001B[2A\u001B[1000D'
 ```
 
 
@@ -135,7 +135,7 @@ See [term-img](https://github.com/sindresorhus/term-img) for a higher-level modu
 
 #### input
 
-Type: `buffer`
+Type: `Buffer`
 
 Buffer of an image. Usually read in with `fs.readFile()`.
 
diff --git a/test.js b/test.js
index 3b17965..f29b656 100644
--- a/test.js
+++ b/test.js
@@ -1,8 +1,8 @@
 import test from 'ava';
-import m from './';
+import m from '.';
 
 test(t => {
 	t.true(Object.keys(m).length > 0);
 	t.is(typeof m.cursorTo, 'function');
-	t.is(m.cursorTo(2, 2), '\u001b[3;3H');
+	t.is(m.cursorTo(2, 2), '\u001B[3;3H');
 });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-ansi-escapes.git



More information about the Pkg-javascript-commits mailing list