Skip to content

Commit

Permalink
Chore: prepare 0.3.1 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Krasnoyarov committed Nov 25, 2016
1 parent 6f1bb49 commit d17d7ff
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 58 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
sudo: false
language: node_js
node_js:
- '7'
- '6'
- '5'
- '4'
Expand Down
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,30 @@ All notable changes to this project will be documented in this file.

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

# Head
# 0.3.1

- Chore: use right semver for `eslint-*`.
- Chore: update a minimal version of `pretty-bytes` from `3.0.0` to `4.0.0`.
- Chore: more full `description`.
- Chore: fix link `dependencies` and `devDependencies`.
- Chore: minimum required `fs-extra` version is now `^1.0.0`.
- Chore: minimum required `ava` version is now `^0.17.0`.
- Chore: minimum required `nyc` version is now `^10.0.0`.
- Chore: minimum required `execa` version is now `^0.5.0`.
- Chore: minimum required `remark-preset-lint-itgalaxy` version is now `^3.0.0`.
- Chore: minimum required `eslint` version is now `^3.10.0`.
- Chore: minimum required `eslint-plugin-ava` version is now `^4.0.0`.
- Chore: minimum required `eslint-plugin-import` version is now `^2.2.0`.
- Chore: minimum required `eslint-plugin-itgalaxy` version is now `^30.0.0`.
- Chore: minimum required `eslint-plugin-jsx-a11y` version is now `^3.0.0`.
- Chore: minimum required `eslint-plugin-lodash` version is now `^2.2.0`.
- Chore: minimum required `eslint-plugin-node` version is now `^3.0.0`.
- Chore: minimum required `eslint-plugin-promise` version is now `^3.4.0`.
- Chore: minimum required `eslint-plugin-react` version is now `^6.7.0`.
- Chore: minimum required `eslint-plugin-xo` version is now `^1.0.0`.
- Chore: rename `eslint-plugin-xo` to `eslint-plugin-unicorn`.
- Chore: add `node.js` vesion `7` to travis CI.
- Fixed: move `replace-ext` from `devDependencies` to `dependencies`.

# 0.3.0

Expand Down
7 changes: 5 additions & 2 deletions __tests__/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test('show help screen', async (t) => {
});

test('show version', async (t) => {
// eslint-disable-line no-global-require
// eslint-disable-next-line global-require
t.is(await execa.stdout('../cli.js', ['--version']), require('../package.json').version);
});

Expand Down Expand Up @@ -218,7 +218,10 @@ test('optimize a corrupt image and a normal image use silent and ignore-errors',

t.regex(output.stderr, /Minifying image "fixtures\/test-corrupt.jpg"/);
t.regex(output.stderr, /Error: Corrupt JPEG data/);
t.notRegex(output.stderr, /Successfully compressed images: 1. Unsuccessfully compressed images: 1. Total images: 2./);
t.notRegex(
output.stderr,
/Successfully compressed images: 1. Unsuccessfully compressed images: 1. Total images: 2./
);
});

test('optimize images use verbose and ignore-errors', async (t) => {
Expand Down
3 changes: 2 additions & 1 deletion __tests__/fixtures/imagemin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict'; // eslint-disable-line strict
// eslint-disable-next-line strict, lines-around-directive
'use strict';

const imageminPngquant = require('imagemin-pngquant');

Expand Down
75 changes: 39 additions & 36 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

'use strict'; // eslint-disable-line strict
'use strict'; // eslint-disable-line strict, lines-around-directive

const arrify = require('arrify');
const fileType = require('file-type');
Expand Down Expand Up @@ -70,7 +70,7 @@ const cli = meow(`
});

/* istanbul ignore if */
if (!cli.input.length && process.stdin.isTTY) {
if (cli.input.length !== 0 && process.stdin.isTTY) {
cli.showHelp();
}

Expand All @@ -85,38 +85,38 @@ const handleFile
return resolve(data);
});
})
.then(
(data) => imagemin.buffer(data, {
plugins: opts.plugin
})
.then((buffer) => {
let parentDirectory = '';

if (opts.recursive) {
parentDirectory = path.relative(opts.cwd, path.dirname(filepath));
}

const dest = path.resolve(path.join(opts.outDir, parentDirectory, path.basename(filepath)));

const ret = {
data: buffer,
optimizedSize: buffer.length,
originalSize: data.length,
path: fileType(buffer) && fileType(buffer).ext === 'webp' ? replaceExt(dest, '.webp') : dest
};

return new Promise(
(resolve, reject) => fs.outputFile(ret.path, ret.data, (error) => {
/* istanbul ignore if */
if (error) {
return reject(error);
}

return resolve(ret);
})
);
.then(
(data) => imagemin.buffer(data, {
plugins: opts.plugin
})
);
.then((buffer) => {
let parentDirectory = '';

if (opts.recursive) {
parentDirectory = path.relative(opts.cwd, path.dirname(filepath));
}

const dest = path.resolve(path.join(opts.outDir, parentDirectory, path.basename(filepath)));

const ret = {
data: buffer,
optimizedSize: buffer.length,
originalSize: data.length,
path: fileType(buffer) && fileType(buffer).ext === 'webp' ? replaceExt(dest, '.webp') : dest
};

return new Promise(
(resolve, reject) => fs.outputFile(ret.path, ret.data, (error) => {
/* istanbul ignore if */
if (error) {
return reject(error);
}

return resolve(ret);
})
);
})
);

const DEFAULT_PLUGINS = [
'gifsicle',
Expand All @@ -128,7 +128,8 @@ const DEFAULT_PLUGINS = [
// eslint-disable-next-line consistent-return, array-callback-return
const requirePlugins = (plugins) => plugins.map((plugin) => {
try {
return require(`imagemin-${plugin}`)(); // eslint-disable-line global-require
// eslint-disable-next-line global-require, import/no-dynamic-require
return require(`imagemin-${plugin}`)();
} catch (error) {
// eslint-disable-next-line no-console
console.error(stripIndent(`
Expand Down Expand Up @@ -159,7 +160,8 @@ const run = (input, options) => {
let config = null;

try {
config = require(path.resolve(dataSource)); // eslint-disable-line global-require
// eslint-disable-next-line global-require, import/no-dynamic-require
config = require(path.resolve(dataSource));
} catch (error) {
console.error(`Cannot require "config"\n${error}`); // eslint-disable-line no-console
process.exit(1); // eslint-disable-line no-process-exit
Expand Down Expand Up @@ -206,6 +208,7 @@ const run = (input, options) => {
.then((paths) => {
// Maybe throw error if not found images

// eslint-disable-next-line promise/always-return
if (!opts.outDir && paths.length > 1) {
// eslint-disable-next-line no-console
console.error('Cannot write multiple files to stdout, specify a `--out-dir`');
Expand Down Expand Up @@ -317,7 +320,7 @@ if (cli.flags.ignoreErrors) {
optionsBase.ignoreErrors = cli.flags.ignoreErrors;
}

if (cli.input.length) {
if (cli.input.length > 0) {
run(cli.input, cli.flags)
.catch((error) => {
console.error(error.stack); // eslint-disable-line no-console
Expand Down
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "imagemin-power-cli",
"version": "0.3.0",
"version": "0.3.1",
"description": "Minify images with imagemin use CLI",
"keywords": [
"cli",
Expand Down Expand Up @@ -37,44 +37,44 @@
"dependencies": {
"arrify": "^1.0.1",
"file-type": "^3.8.0",
"fs-extra": "^0.30.0",
"fs-extra": "^1.0.0",
"get-stdin": "^5.0.1",
"globby": "^6.0.0",
"imagemin": "^5.0.0",
"meow": "^3.6.0",
"ora": "^0.3.0",
"plur": "^2.1.2",
"pretty-bytes": "^4.0.0",
"strip-indent": "^2.0.0"
"strip-indent": "^2.0.0",
"replace-ext": "^1.0.0"
},
"devDependencies": {
"ava": "^0.16.0",
"ava": "^0.17.0",
"babel-cli": "^6.11.0",
"babel-core": "^6.13.0",
"babel-preset-es2015": "^6.13.0",
"babel-preset-stage-0": "^6.5.0",
"babel-register": "^6.9.0",
"coveralls": "^2.11.0",
"eslint": "^3.4.0",
"eslint-plugin-ava": "^3.0.0",
"eslint-plugin-import": "^1.14.0",
"eslint-plugin-itgalaxy": "^13.0.0",
"eslint-plugin-jsx-a11y": "^2.2.0",
"eslint-plugin-lodash": "^1.10.0",
"eslint-plugin-node": "^2.0.0",
"eslint-plugin-promise": "^2.0.0",
"eslint-plugin-react": "^6.2.0",
"eslint-plugin-xo": "^0.5.0",
"execa": "^0.4.0",
"eslint": "^3.10.0",
"eslint-plugin-ava": "^4.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-itgalaxy": "^30.0.0",
"eslint-plugin-jsx-a11y": "^3.0.0",
"eslint-plugin-lodash": "^2.2.0",
"eslint-plugin-node": "^3.0.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-react": "^6.7.0",
"eslint-plugin-unicorn": "^1.0.0",
"execa": "^0.5.0",
"imagemin-pngquant": "^5.0.0",
"npmpub": "^3.1.0",
"npm-run-all": "^3.0.0",
"nyc": "^8.1.0",
"nyc": "^10.0.0",
"pify": "^2.3.0",
"remark-cli": "^2.0.0",
"remark-lint": "^5.0.0",
"remark-preset-lint-itgalaxy": "^1.0.0",
"replace-ext": "^1.0.0",
"remark-preset-lint-itgalaxy": "^3.0.0",
"rimraf": "^2.5.2"
},
"optionalDependencies": {
Expand Down

0 comments on commit d17d7ff

Please sign in to comment.