Skip to content

Commit

Permalink
Require Node.js 6
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jan 28, 2019
1 parent e6a876d commit 5f93eca
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 26 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js:
- '10'
- '8'
- '6'
- '4'
28 changes: 13 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ x.cursorMove = (x, y) => {
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.cursorUp = (count = 1) => ESC + count + 'A';
x.cursorDown = (count = 1) => ESC + count + 'B';
x.cursorForward = (count = 1) => ESC + count + 'C';
x.cursorBackward = (count = 1) => ESC + count + 'D';

x.cursorLeft = ESC + 'G';
x.cursorSavePosition = ESC + (isTerminalApp ? '7' : 's');
Expand Down Expand Up @@ -106,26 +106,24 @@ x.link = (text, url) => {
].join('');
};

x.image = (buf, opts) => {
opts = opts || {};
x.image = (buffer, options = {}) => {
let ret = `${OSC}1337;File=inline=1`;

let ret = OSC + '1337;File=inline=1';

if (opts.width) {
ret += `;width=${opts.width}`;
if (options.width) {
ret += `;width=${options.width}`;
}

if (opts.height) {
ret += `;height=${opts.height}`;
if (options.height) {
ret += `;height=${options.height}`;
}

if (opts.preserveAspectRatio === false) {
if (options.preserveAspectRatio === false) {
ret += ';preserveAspectRatio=0';
}

return ret + ':' + buf.toString('base64') + BEL;
return ret + ':' + buffer.toString('base64') + BEL;
};

x.iTerm = {};

x.iTerm.setCwd = cwd => OSC + '50;CurrentDir=' + (cwd || process.cwd()) + BEL;
x.iTerm.setCwd = (cwd = process.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`;
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
Expand Down Expand Up @@ -44,7 +44,7 @@
"iterm2"
],
"devDependencies": {
"ava": "*",
"xo": "*"
"ava": "^1.2.0",
"xo": "^0.24.0"
}
}
10 changes: 5 additions & 5 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import test from 'ava';
import m from '.';
import ansiEscapes 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');
test('main', t => {
t.true(Object.keys(ansiEscapes).length > 0);
t.is(typeof ansiEscapes.cursorTo, 'function');
t.is(ansiEscapes.cursorTo(2, 2), '\u001B[3;3H');
});

0 comments on commit 5f93eca

Please sign in to comment.