-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·67 lines (53 loc) · 1.21 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#! /usr/bin/env node
const debug = require('./lib/debug');
const bulkResize = require('./lib/bulk-resize');
const argv = require('yargs')
.usage('Usage: bulk-resize -s [kb] -d [path]')
.demand('t')
.option('s', {
alias: 'source',
default: process.cwd(),
describe: 'Path to input file/s.',
type: 'string'
})
.option('d', {
alias: 'destination',
default: process.cwd() + '/resized',
describe: 'Path to output file/s.',
type: 'string'
})
.option('t', {
alias: 'aimSize',
describe: 'Size to aim for when tinkering image quality.',
type: 'number'
})
.option('b', {
alias: 'bigger',
describe: 'Width for horizontal images and height for vertical images, of output file/s in pixels',
type: 'number'
})
.option('h', {
alias: 'height',
describe: 'Height of output file/s in pixels',
type: 'number'
})
.option('w', {
alias: 'width',
describe: 'Width of output file/s in pixels',
type: 'number'
})
.option('debug', {
describe: 'Show debugging info',
type: 'boolean',
default: false
})
.help('help')
.wrap()
.argv;
const log = debug(argv.debug);
log({argv});
bulkResize(argv)
.catch(err => {
if (argv.debug) return log(err.stack);
console.error(err.message)
});