From 7ed83126affad00a7491fee5453d264873f66bd9 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 21 May 2020 13:33:33 +0800 Subject: [PATCH] Require Node.js 10 --- .travis.yml | 3 ++- index.d.ts | 4 ++-- index.test-d.ts | 2 +- license | 2 +- package.json | 11 ++++++----- readme.md | 19 ++++++------------- 6 files changed, 18 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index 225084f..d50cc60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ os: osx language: node_js node_js: + - '14' + - '12' - '10' - - '8' diff --git a/index.d.ts b/index.d.ts index 619e339..6d53ba2 100644 --- a/index.d.ts +++ b/index.d.ts @@ -21,6 +21,8 @@ declare namespace termImg { } declare const termImg: { + UnsupportedTerminalError: typeof UnsupportedTerminalErrorClass; + /** Get the image as a `string` that you can log manually. @@ -41,8 +43,6 @@ declare const termImg: { image: string | Buffer, options?: termImg.Options ): string | FallbackType; - - UnsupportedTerminalError: typeof UnsupportedTerminalErrorClass; }; export = termImg; diff --git a/index.test-d.ts b/index.test-d.ts index d5a4cac..1468ed2 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -5,7 +5,7 @@ import {UnsupportedTerminalError} from '.'; expectType(termImg('/foo/bar.jpg')); expectType(termImg(Buffer.alloc(1))); expectType(termImg('/foo/bar.jpg', {width: 1})); -expectType( +expectType( termImg('/foo/bar.jpg', {fallback: () => false}) ); diff --git a/license b/license index e7af2f7..fa7ceba 100644 --- a/license +++ b/license @@ -1,6 +1,6 @@ MIT License -Copyright (c) Sindre Sorhus (sindresorhus.com) +Copyright (c) Sindre Sorhus (https://sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/package.json b/package.json index f51ed83..4fe6aba 100644 --- a/package.json +++ b/package.json @@ -4,13 +4,14 @@ "description": "Display images in iTerm", "license": "MIT", "repository": "sindresorhus/term-img", + "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" + "url": "https://sindresorhus.com" }, "engines": { - "node": ">=8" + "node": ">=10" }, "scripts": { "test": "xo && ava && tsd" @@ -46,9 +47,9 @@ "iterm2-version": "^4.1.0" }, "devDependencies": { - "@types/node": "^12.0.7", + "@types/node": "^14.0.4", "ava": "^2.0.0", - "tsd": "^0.7.2", - "xo": "^0.24.0" + "tsd": "^0.11.0", + "xo": "^0.30.0" } } diff --git a/readme.md b/readme.md index 8d15c81..bd14c31 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# term-img [![Build Status](https://travis-ci.org/sindresorhus/term-img.svg?branch=master)](https://travis-ci.org/sindresorhus/term-img) +# term-img [![Build Status](https://travis-ci.com/sindresorhus/term-img.svg?branch=master)](https://travis-ci.com/github/sindresorhus/term-img) > Display images in iTerm @@ -10,14 +10,12 @@ Even [animated gifs](https://github.com/vdemedes/gifi)! *Currently only supported on [iTerm >=3](https://www.iterm2.com/downloads.html).* - ## Install ``` $ npm install term-img ``` - ## Usage ```js @@ -30,10 +28,9 @@ function fallback() { console.log(termImg('unicorn.jpg', {fallback})); ``` - ## API -### termImg(image, [options]) +### termImg(image, options?) Get the image as a `string` that you can log manually. @@ -45,6 +42,8 @@ Filepath to an image or an image as a buffer. #### options +Type: `object` + ##### width ##### height @@ -59,22 +58,16 @@ The width and height are given as a number followed by a unit, or the word `'aut ##### preserveAspectRatio -Type: `boolean`
+Type: `boolean`\ Default: `true` ##### fallback -Type: `Function`
+Type: `Function`\ Default: `() => throw new UnsupportedTerminalError()` Enables you to do something else when the terminal doesn't support images. - ## Related - [term-img-cli](https://github.com/sindresorhus/term-img-cli) - CLI for this module - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com)