From fbc75f9212f03dc0c298139feee05e12e1d619c8 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Tue, 8 May 2018 20:47:06 +0700 Subject: [PATCH] Require Node.js 6 --- .gitattributes | 3 +- .travis.yml | 2 +- index.js | 22 ++++++------ package.json | 98 +++++++++++++++++++++++++------------------------- readme.md | 2 +- test.js | 2 +- 6 files changed, 63 insertions(+), 66 deletions(-) diff --git a/.gitattributes b/.gitattributes index 391f0a4..6313b56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1 @@ -* text=auto -*.js text eol=lf +* text=auto eol=lf diff --git a/.travis.yml b/.travis.yml index 49fd032..9efad1a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ os: osx language: node_js node_js: + - '10' - '8' - '6' - - '4' diff --git a/index.js b/index.js index 7d7e851..0145922 100644 --- a/index.js +++ b/index.js @@ -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'); } @@ -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(); @@ -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(); diff --git a/package.json b/package.json index 4069034..4ea1325 100644 --- a/package.json +++ b/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": "*" + } } diff --git a/readme.md b/readme.md index 7292eba..0a5309e 100644 --- a/readme.md +++ b/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) diff --git a/test.js b/test.js index 4386b96..698714a 100644 --- a/test.js +++ b/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'); });