Skip to content

Commit

Permalink
Adding mute option. (#88)
Browse files Browse the repository at this point in the history
* Adding mute option.

* Cleaning up.

Co-authored-by: Mgs. M. Rizqi Fadhlurrahman <rizqirizqi23@gmail.com>
  • Loading branch information
maliMirkec and rizqirizqi authored Dec 8, 2021
1 parent 41515fa commit 0395171
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,23 @@ CLI Converter from png/jpg images to webp
webpconvert sample-images
webpconvert sample-images -q 50
webpconvert sample-images output
webpconvert sample-images -m
webpconvert sample-images/KittenJPG.jpg
```

### Options

| Option | Option alias | Description | Type | Default |
|--------|--------------|-------------------------------------------------------------------------------------------------------|---------|---------|
| -p | --prefix | Specify the prefix of output filename. | string | "" |
| -s | --suffix | Specify the suffix of output filename. | string | "" |
| -q | --quality | Specify the quality of webp image. Lower values yield better compression but the least image quality. | number | 80 |
| -m | --mute | Disable output messages. | boolean | |
| -h | --help | Show help. | boolean | |
| -v | --version | Show version number. | boolean | |

```
### Help
```bash
webpconvert --help
Expand Down
1 change: 1 addition & 0 deletions __snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Options:
-p, --prefix Specify the prefix of output filename. [string] [default: \\"\\"]
-s, --suffix Specify the suffix of output filename. [string] [default: \\"\\"]
-q, --quality Specify the quality of webp image. Lower values yield better compression but the least image quality. [number] [default: 80]
-m, --mute Disable output messages. [boolean] [default: false]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Expand Down
14 changes: 12 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ const { argv } = yargs(hideBin(process.argv))
type: 'number',
requiresArg: true,
})
.options('m', {
alias: 'mute',
demandOption: false,
default: false,
describe: 'Disable output messages.',
type: 'boolean',
requiresArg: false,
})
.help()
.alias('help', 'h')
.version()
Expand Down Expand Up @@ -84,7 +92,8 @@ if (PNGImages) {
.pipe(imagemin([webp({
quality: argv.quality,
})], {
verbose: true,
verbose: !argv.mute,
silent: false
}))
.pipe(rename({ prefix: argv.prefix, suffix: `${argv.suffix}.png`, extname: '.webp' }))
.pipe(gulp.dest(target));
Expand All @@ -95,7 +104,8 @@ if (JPGImages) {
.pipe(imagemin([webp({
quality: argv.quality,
})], {
verbose: true,
verbose: !argv.mute,
silent: false
}))
.pipe(rename({ prefix: argv.prefix, suffix: `${argv.suffix}.jpg`, extname: '.webp' }))
.pipe(gulp.dest(target));
Expand Down

0 comments on commit 0395171

Please sign in to comment.