summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/ansi-escapes/index.js
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2017-12-22 16:53:42 +0100
committerMichaël Zasso <targos@protonmail.com>2018-01-11 09:48:05 +0100
commit3dc30632755713179f345f4af024bd904c6162d0 (patch)
treef28c4f6dd6dfc5992edf301449d1a371d229755b /tools/node_modules/eslint/node_modules/ansi-escapes/index.js
parenta2c7085dd4a8e60d1a47572aca8bb6fcb7a32f88 (diff)
downloadandroid-node-v8-3dc30632755713179f345f4af024bd904c6162d0.tar.gz
android-node-v8-3dc30632755713179f345f4af024bd904c6162d0.tar.bz2
android-node-v8-3dc30632755713179f345f4af024bd904c6162d0.zip
tools: move eslint from tools to tools/node_modules
This is required because we need to add the babel-eslint dependency and it has to be able to resolve "eslint". babel-eslint is required to support future ES features such as async iterators and import.meta. Refs: https://github.com/nodejs/node/pull/17755 PR-URL: https://github.com/nodejs/node/pull/17820 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'tools/node_modules/eslint/node_modules/ansi-escapes/index.js')
-rw-r--r--tools/node_modules/eslint/node_modules/ansi-escapes/index.js102
1 files changed, 102 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/ansi-escapes/index.js b/tools/node_modules/eslint/node_modules/ansi-escapes/index.js
new file mode 100644
index 0000000000..4d47b1098d
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/ansi-escapes/index.js
@@ -0,0 +1,102 @@
+'use strict';
+const x = module.exports;
+const ESC = '\u001B[';
+const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';
+
+x.cursorTo = (x, y) => {
+ if (typeof x !== 'number') {
+ throw new TypeError('The `x` argument is required');
+ }
+
+ if (typeof y !== 'number') {
+ return ESC + (x + 1) + 'G';
+ }
+
+ return ESC + (y + 1) + ';' + (x + 1) + 'H';
+};
+
+x.cursorMove = (x, y) => {
+ if (typeof x !== 'number') {
+ throw new TypeError('The `x` argument is required');
+ }
+
+ let ret = '';
+
+ if (x < 0) {
+ ret += ESC + (-x) + 'D';
+ } else if (x > 0) {
+ ret += ESC + x + 'C';
+ }
+
+ if (y < 0) {
+ ret += ESC + (-y) + 'A';
+ } else if (y > 0) {
+ ret += ESC + y + 'B';
+ }
+
+ return ret;
+};
+
+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.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 = count => {
+ let clear = '';
+
+ for (let i = 0; i < count; i++) {
+ clear += x.eraseLine + (i < count - 1 ? x.cursorUp() : '');
+ }
+
+ if (count) {
+ clear += x.cursorLeft;
+ }
+
+ return clear;
+};
+
+x.eraseEndLine = ESC + 'K';
+x.eraseStartLine = ESC + '1K';
+x.eraseLine = ESC + '2K';
+x.eraseDown = ESC + 'J';
+x.eraseUp = ESC + '1J';
+x.eraseScreen = ESC + '2J';
+x.scrollUp = ESC + 'S';
+x.scrollDown = ESC + 'T';
+
+x.clearScreen = '\u001Bc';
+x.beep = '\u0007';
+
+x.image = (buf, opts) => {
+ opts = opts || {};
+
+ let ret = '\u001B]1337;File=inline=1';
+
+ if (opts.width) {
+ ret += `;width=${opts.width}`;
+ }
+
+ if (opts.height) {
+ ret += `;height=${opts.height}`;
+ }
+
+ if (opts.preserveAspectRatio === false) {
+ ret += ';preserveAspectRatio=0';
+ }
+
+ return ret + ':' + buf.toString('base64') + '\u0007';
+};
+
+x.iTerm = {};
+
+x.iTerm.setCwd = cwd => '\u001B]50;CurrentDir=' + (cwd || process.cwd()) + '\u0007';