terminal-image-cli 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/cli.js +20 -17
  2. package/package.json +9 -9
  3. package/readme.md +3 -3
package/cli.js CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
+ import process from 'node:process';
2
3
  import meow from 'meow';
3
4
  import getStdin from 'get-stdin';
4
5
  import terminalImage from 'terminal-image';
5
- import fileType from 'file-type';
6
+ import {fileTypeFromFile, fileTypeFromBuffer} from 'file-type';
6
7
 
7
8
  const cli = meow(`
8
9
  Usage
@@ -12,7 +13,9 @@ const cli = meow(`
12
13
  Examples
13
14
  $ image unicorn.jpg
14
15
  $ cat unicorn.jpg | image
15
- `);
16
+ `, {
17
+ importMeta: import.meta,
18
+ });
16
19
 
17
20
  const [input] = cli.input;
18
21
 
@@ -21,21 +24,21 @@ if (!input && process.stdin.isTTY) {
21
24
  process.exit(1);
22
25
  }
23
26
 
24
- (async () => {
25
- if (input) {
26
- // TODO: Make it `if ((await fileType.fromFile(input))?.ext === 'gif') {` when targeting Node.js 14.
27
- if ((await fileType.fromFile(input)).ext === 'gif') {
28
- terminalImage.gifFile(input);
29
- } else {
30
- console.log(await terminalImage.file(input));
31
- }
27
+ if (input) {
28
+ const {ext} = await fileTypeFromFile(input);
29
+
30
+ if (ext === 'gif') {
31
+ terminalImage.gifFile(input);
32
32
  } else {
33
- const stdin = await getStdin.buffer();
33
+ console.log(await terminalImage.file(input));
34
+ }
35
+ } else {
36
+ const stdin = await getStdin.buffer();
37
+ const {ext} = await fileTypeFromBuffer(stdin);
34
38
 
35
- if ((await fileType.fromBuffer(stdin)).ext === 'gif') {
36
- terminalImage.gifBuffer(stdin);
37
- } else {
38
- console.log(await terminalImage.buffer(stdin));
39
- }
39
+ if (ext === 'gif') {
40
+ terminalImage.gifBuffer(stdin);
41
+ } else {
42
+ console.log(await terminalImage.buffer(stdin));
40
43
  }
41
- })();
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terminal-image-cli",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "description": "Display images in the terminal",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/terminal-image-cli",
@@ -15,7 +15,7 @@
15
15
  "image": "./cli.js"
16
16
  },
17
17
  "engines": {
18
- "node": ">=12"
18
+ "node": ">=18"
19
19
  },
20
20
  "scripts": {
21
21
  "test": "xo && FORCE_COLOR=1 ava"
@@ -38,15 +38,15 @@
38
38
  "animation"
39
39
  ],
40
40
  "dependencies": {
41
- "file-type": "^16.3.0",
41
+ "file-type": "^19.3.0",
42
42
  "get-stdin": "^9.0.0",
43
- "meow": "^9.0.0",
44
- "terminal-image": "^2.0.0"
43
+ "meow": "^13.2.0",
44
+ "terminal-image": "^3.0.0"
45
45
  },
46
46
  "devDependencies": {
47
- "ava": "^3.15.0",
48
- "execa": "^5.0.0",
49
- "has-ansi": "^5.0.0",
50
- "xo": "^0.39.1"
47
+ "ava": "^6.1.3",
48
+ "execa": "^9.3.0",
49
+ "has-ansi": "^6.0.0",
50
+ "xo": "^0.59.2"
51
51
  }
52
52
  }
package/readme.md CHANGED
@@ -10,8 +10,8 @@ Works in any terminal that supports colors. Supports animated GIFs.
10
10
 
11
11
  ## Install
12
12
 
13
- ```
14
- $ npm install --global terminal-image-cli
13
+ ```sh
14
+ npm install --global terminal-image-cli
15
15
  ```
16
16
 
17
17
  ## Usage
@@ -30,5 +30,5 @@ $ image --help
30
30
 
31
31
  ## Related
32
32
 
33
- - [terminal-image](https://github.com/sindresorhus/terminal-image) - API for this module
33
+ - [terminal-image](https://github.com/sindresorhus/terminal-image) - API for this package
34
34
  - [terminal-link-cli](https://github.com/sindresorhus/terminal-link-cli) - Create clickable links in the terminal