Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding mute option. #88

Merged
merged 4 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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