| 'use strict' | ||
| const Configstore = require('configstore') | ||
| const tinify = require('tinify') | ||
| async function compress (source) { | ||
| try { | ||
| const configuration = new Configstore('clipix', {}) | ||
| const key = configuration.get('tinify') | ||
| if (!key) { | ||
| throw new Error('Tinify key not found. Remember to use clipix config tinify <KeyValue> first') | ||
| } | ||
| tinify.key = key | ||
| const file = tinify.fromFile(source) | ||
| return file.toFile(`optimized-${source}`) | ||
| } catch (error) { | ||
| console.error(error.message) | ||
| } | ||
| } | ||
| module.exports = compress |
| 'use strict' | ||
| const Configstore = require('configstore') | ||
| async function config (command, value) { | ||
| const configuration = new Configstore('clipix', {}) | ||
| configuration.set(command, value) | ||
| } | ||
| module.exports = config |
+12
-0
@@ -11,2 +11,4 @@ #!/usr/bin/env node | ||
| const Image = require('../src/lib/image') | ||
| const compress = require('../src/commands/compress') | ||
| const config = require('../src/commands/config') | ||
@@ -52,2 +54,12 @@ async function action (source) { | ||
| program | ||
| .command('compress <Image>') | ||
| .description('Compress an image') | ||
| .action(compress) | ||
| program | ||
| .command('config <Command> <Value>') | ||
| .description('Save command configuration') | ||
| .action(config) | ||
| program.parse(process.argv) | ||
@@ -54,0 +66,0 @@ } |
+4
-2
| { | ||
| "name": "clipix", | ||
| "version": "0.0.1", | ||
| "version": "0.2.0", | ||
| "description": "Clipix, an nice image editor for the terminal created in Nodejs ", | ||
@@ -20,2 +20,3 @@ "main": "index.js", | ||
| "commander": "^6.2.0", | ||
| "configstore": "^5.0.1", | ||
| "emojic": "^1.1.16", | ||
@@ -25,3 +26,4 @@ "file-type": "^16.0.1", | ||
| "log-symbols": "^4.0.0", | ||
| "sharp": "^0.26.3" | ||
| "sharp": "^0.26.3", | ||
| "tinify": "^1.6.0-beta.2" | ||
| }, | ||
@@ -28,0 +30,0 @@ "devDependencies": { |
3471300
0.03%10
25%133
35.71%8
33.33%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added