| 'use strict' | ||
| const logSymbols = require('log-symbols') | ||
| const fs = require('fs').promises | ||
| const Image = require('../lib/image') | ||
| module.exports = async function action (source) { | ||
| try { | ||
| const sourceStat = await fs.lstat(source) | ||
| const sources = !sourceStat.isDirectory() ? [source] : await fs.readdir(source) | ||
| const images = await Promise.all(sources.map(async file => { | ||
| const isImage = await Image.isImage(file) | ||
| if (!isImage) return false | ||
| const image = new Image(file) | ||
| const { format, width, height, _size } = await image.metadata() | ||
| return { | ||
| file: file, | ||
| format, | ||
| width, | ||
| height, | ||
| _size | ||
| } | ||
| })) | ||
| console.table(images.filter(i => i)) | ||
| } catch (error) { | ||
| console.error(logSymbols.error, error.message) | ||
| } | ||
| } |
+2
-32
@@ -6,9 +6,7 @@ #!/usr/bin/env node | ||
| const { Command } = require('commander') | ||
| const logSymbols = require('log-symbols') | ||
| const { version } = require('../package.json') | ||
| const emojic = require('emojic') | ||
| const fs = require('fs').promises | ||
| const Image = require('../src/lib/image') | ||
| const compress = require('../src/commands/compress') | ||
| const config = require('../src/commands/config') | ||
| const info = require('../src/commands/info') | ||
| const updateNotifier = require('update-notifier') | ||
@@ -19,30 +17,2 @@ const pkg = require('../package.json') | ||
| async function action (source) { | ||
| try { | ||
| const sourceStat = await fs.lstat(source) | ||
| const sources = !sourceStat.isDirectory() ? [source] : await fs.readdir(source) | ||
| const images = await Promise.all(sources.map(async file => { | ||
| const isImage = await Image.isImage(file) | ||
| if (!isImage) return false | ||
| const image = new Image(file) | ||
| const { format, width, height, _size } = await image.metadata() | ||
| return { | ||
| file: file, | ||
| format, | ||
| width, | ||
| height, | ||
| _size | ||
| } | ||
| })) | ||
| console.table(images.filter(i => i)) | ||
| } catch (error) { | ||
| console.error(logSymbols.error, error.message) | ||
| } | ||
| } | ||
| async function init () { | ||
@@ -57,3 +27,3 @@ const program = new Command() | ||
| .description('Get the information from an image') | ||
| .action(action) | ||
| .action(info) | ||
@@ -60,0 +30,0 @@ program |
+1
-1
| { | ||
| "name": "clipix", | ||
| "version": "0.4.0", | ||
| "version": "0.4.1", | ||
| "description": "Clipix, nice image editor for the terminal created in Nodejs", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
3471625
011
10%139
1.46%