Skip to content

Commit

Permalink
feat: update packages and configuration options
Browse files Browse the repository at this point in the history
updated all packages
added feature from this PR, amended to latest setup
  • Loading branch information
davidsneighbour authored Jan 22, 2024
2 parents 9882d7c + cbfb40d commit b518341
Show file tree
Hide file tree
Showing 4 changed files with 13,978 additions and 44 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ N/A
[npm-image]: https://img.shields.io/npm/v/imagemin-lint-staged.svg?style=flat-square
[npm-url]: https://www.npmjs.org/package/imagemin-lint-staged

[github-workflows-pr-image]: https://github.com/tomchentw/imagemin-lint-staged/actions/workflows/pr.yml/badge.svg
[github-workflows-pr-url]: https://github.com/tomchentw/imagemin-lint-staged/actions/workflows/pr.yml
[github-workflows-pr-image]: https://github.com/davidsneighbour/imagemin-lint-staged/actions/workflows/pr.yml/badge.svg
[github-workflows-pr-url]: https://github.com/davidsneighbour/imagemin-lint-staged/actions/workflows/pr.yml
68 changes: 40 additions & 28 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,56 @@
"use strict";
const fs = require("fs");
const promisify = require("util.promisify");
'use strict';
const fs = require('fs');
const promisify = require('util.promisify');
const { cosmiconfigSync } = require('cosmiconfig');

const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);

const plugins = [
[
"imagemin-gifsicle",
{
interlaced: true,
},
],
[
"imagemin-jpegtran",
{
progressive: true,
},
],
[
"imagemin-optipng",
{
optimizationLevel: 5,
},
],
[
"imagemin-svgo",
{
const explorerSync = cosmiconfigSync('imagemin-lint-staged');
const { config } = explorerSync.search() || { config: false };

const gifsicleConfig =
config && config.gifsicle
? config.gifsicle
: {
interlaced: true
};

const jpegtranConfig =
config && config.jpegtran
? config.jpegtran
: {
progressive: true
};

const optipngConfig =
config && config.optipng
? config.optipng
: {
optimizationLevel: 5
};

const svgoConfig =
config && config.svgo
? config.svgo
: {
plugins: [
{
name: "preset-default",
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
},
},
},
],
},
],
};

const plugins = [
['imagemin-gifsicle', gifsicleConfig],
['imagemin-jpegtran', jpegtranConfig],
['imagemin-optipng', optipngConfig],
['imagemin-svgo', svgoConfig],
].map(([name, opts]) => require(name)(opts));

const minifyFile = (exports.minifyFile = (filename) =>
Expand Down
Loading

0 comments on commit b518341

Please sign in to comment.