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 May 8, 2018
1 parent 6d014c8 commit fbc75f9
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 66 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,6 +1,6 @@
os: osx
language: node_js
node_js:
- '10'
- '8'
- '6'
- '4'
22 changes: 10 additions & 12 deletions index.js
Expand Up @@ -14,12 +14,10 @@ function unsupported() {
throw new UnsupportedTerminalError();
}

function main(img, opts) {
opts = opts || {};
function main(image, options = {}) {
const fallback = typeof options.fallback === 'function' ? options.fallback : unsupported;

const fallback = typeof opts.fallback === 'function' ? opts.fallback : unsupported;

if (!(img && img.length > 0)) {
if (!(image && image.length > 0)) {
throw new TypeError('Image required');
}

Expand All @@ -33,15 +31,15 @@ function main(img, opts) {
return fallback;
}

if (typeof img === 'string') {
img = fs.readFileSync(img);
if (typeof image === 'string') {
image = fs.readFileSync(image);
}

return ansiEscapes.image(img, opts);
return ansiEscapes.image(image, options);
}

module.exports = (img, opts) => {
const ret = main(img, opts);
module.exports = (image, options) => {
const ret = main(image, options);

if (typeof ret === 'function') {
ret();
Expand All @@ -51,8 +49,8 @@ module.exports = (img, opts) => {
console.log(ret);
};

module.exports.string = (img, opts) => {
const ret = main(img, opts);
module.exports.string = (image, options) => {
const ret = main(image, options);

if (typeof ret === 'function') {
return ret();
Expand Down
98 changes: 49 additions & 49 deletions package.json
@@ -1,51 +1,51 @@
{
"name": "term-img",
"version": "2.1.0",
"description": "Display images in your terminal",
"license": "MIT",
"repository": "sindresorhus/term-img",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"term",
"image",
"iterm",
"iterm2",
"terminal",
"shell",
"console",
"command-line",
"img",
"pic",
"picture",
"photo",
"app",
"version",
"ansi",
"escape",
"gif",
"gifs",
"jpg",
"jpeg"
],
"dependencies": {
"ansi-escapes": "^2.0.0",
"iterm2-version": "^2.1.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
}
"name": "term-img",
"version": "2.1.0",
"description": "Display images in iTerm",
"license": "MIT",
"repository": "sindresorhus/term-img",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"term",
"image",
"iterm",
"iterm2",
"terminal",
"shell",
"console",
"command-line",
"img",
"pic",
"picture",
"photo",
"app",
"version",
"ansi",
"escape",
"gif",
"gifs",
"jpg",
"jpeg"
],
"dependencies": {
"ansi-escapes": "^3.1.0",
"iterm2-version": "^2.1.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
}
}
2 changes: 1 addition & 1 deletion readme.md
@@ -1,6 +1,6 @@
# term-img [![Build Status](https://travis-ci.org/sindresorhus/term-img.svg?branch=master)](https://travis-ci.org/sindresorhus/term-img)

> Display images in your terminal
> Display images in iTerm
![](screenshot.jpg)

Expand Down
2 changes: 1 addition & 1 deletion test.js
@@ -1,7 +1,7 @@
import test from 'ava';
import m from '.';

test(t => {
test('main', t => {
// TODO: Write some real tests
t.is(typeof m, 'function');
});

0 comments on commit fbc75f9

Please sign in to comment.