Skip to content

Commit

Permalink
Chore: prepare 0.4.0-alpha.1 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Dec 22, 2016
1 parent 3e69ac0 commit e8d5f7a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](http://semver.org/).

# 0.4.0-alpha.1

- Added: parallelization minify process.

# 0.3.2

- Fixed: regression error when input not empty.
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ npm install --save imagemin-power-cli

Options:

-c, --config Configuration for plugins, need export \`plugins\`.
-d, --cwd Current working directory.
-p, --plugin Override the default plugins.
-o, --out-dir Output directory.
-r, --recursive Run the command recursively.
-i, --ignore-errors Not stop on errors (it works with only with <path|glob>).
-s --silent Reported only errors.
-v, --verbose Reported everything.

Examples:

-c, --config Configuration for plugins, need export \`plugins\`.
-d, --cwd Current working directory.
-m, --max-concurrency Sets the maximum number of instances of Imagemin that can run at once.
-p, --plugin Override the default plugins.
-o, --out-dir Output directory.
-r, --recursive Run the command recursively.
-i, --ignore-errors Not stop on errors (it works with only with <path|glob>).
-s --silent Reported only errors.
-v, --verbose Reported everything.

Examples
$ imagemin-power images/* --out-dir=build
$ imagemin-power foo.png > foo-optimized.png
$ cat foo.png | imagemin-power > foo-optimized.png
Expand Down
30 changes: 20 additions & 10 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const path = require('path');
const prettyBytes = require('pretty-bytes');
const replaceExt = require('replace-ext');
const stripIndent = require('strip-indent');
const os = require('os');
const createThrottle = require('async-throttle');

const cli = meow(`
Usage
Expand All @@ -30,14 +32,15 @@ const cli = meow(`
Options:
-c, --config Configuration for plugins, need export \`plugins\`.
-d, --cwd Current working directory.
-p, --plugin Override the default plugins.
-o, --out-dir Output directory.
-r, --recursive Run the command recursively.
-i, --ignore-errors Not stop on errors (it works with only with <path|glob>).
-s --silent Reported only errors.
-v, --verbose Reported everything.
-c, --config Configuration for plugins, need export \`plugins\`.
-d, --cwd Current working directory.
-m, --max-concurrency Sets the maximum number of instances of Imagemin that can run at once.
-p, --plugin Override the default plugins.
-o, --out-dir Output directory.
-r, --recursive Run the command recursively.
-i, --ignore-errors Not stop on errors (it works with only with <path|glob>).
-s --silent Reported only errors.
-v, --verbose Reported everything.
Examples
$ imagemin-power images/* --out-dir=build
Expand Down Expand Up @@ -147,6 +150,7 @@ const run = (input, options) => {
const opts = Object.assign({
config: null,
cwd: process.cwd(),
maxConcurrency: os.cpus().length,
// Info support multiple plugins
plugin: DEFAULT_PLUGINS,
recursive: false,
Expand Down Expand Up @@ -196,6 +200,8 @@ const run = (input, options) => {
return Promise.reject(new TypeError('Expected an array'));
}

const throttle = createThrottle(opts.maxConcurrency);

let successCounter = 0;
let failCounter = 0;
let totalBytes = 0;
Expand All @@ -215,7 +221,7 @@ const run = (input, options) => {
process.exit(1); // eslint-disable-line no-process-exit
}

return Promise.all(paths.map((filepath) => {
return Promise.all(paths.map((filepath) => throttle(() => {
const realFilepath = path.join(opts.cwd, filepath);
const total = paths.length;

Expand Down Expand Up @@ -265,7 +271,7 @@ const run = (input, options) => {
return Promise.reject(error);
}
);
}));
})));
})
.then((files) => {
if (opts.verbose) {
Expand Down Expand Up @@ -300,6 +306,10 @@ if (cli.flags.cwd) {
optionsBase.cwd = cli.flags.cwd;
}

if (cli.flags.maxConcurrency) {
optionsBase.maxConcurrency = cli.flags.maxConcurrency;
}

if (cli.flags.plugin) {
optionsBase.plugin = cli.flags.plugin;
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "imagemin-power-cli",
"version": "0.3.2",
"version": "0.4.0-alpha.1",
"description": "Minify images with imagemin use CLI",
"keywords": [
"cli",
Expand Down Expand Up @@ -36,6 +36,7 @@
],
"dependencies": {
"arrify": "^1.0.1",
"async-throttle": "^1.0.0",
"file-type": "^4.0.0",
"fs-extra": "^1.0.0",
"get-stdin": "^5.0.1",
Expand Down

0 comments on commit e8d5f7a

Please sign in to comment.