Skip to content

Commit

Permalink
feat(imagemin): replace tiny-glob with fast-glob (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed May 2, 2023
1 parent d295128 commit 735e9ff
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-planes-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@pkgr/imagemin": minor
---

feat(imagemin): replace tiny-glob with fast-glob
4 changes: 2 additions & 2 deletions packages/imagemin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"funding": "https://opencollective.com/unts",
"license": "MIT",
"engines": {
"node": "^12.20.0 || ^14.18.0 || >=16.0.0"
"node": ">=16.0.0"
},
"bin": {
"i": "lib/cli.js"
Expand All @@ -26,6 +26,7 @@
"lib"
],
"dependencies": {
"fast-glob": "^3.2.12",
"imagemin": "^8.0.1",
"imagemin-gifsicle": "^7.0.0",
"imagemin-jpegtran": "^7.0.0",
Expand All @@ -36,7 +37,6 @@
"imagemin-upng": "^4.0.0",
"imagemin-webp": "^8.0.0",
"is-glob": "^4.0.3",
"tiny-glob": "^0.2.9",
"tslib": "^2.5.0"
},
"publishConfig": {
Expand Down
13 changes: 6 additions & 7 deletions packages/imagemin/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node

import glob from 'fast-glob'
import isGlob from 'is-glob'
import glob from 'tiny-glob'

import imagemin from './index.js'

Expand All @@ -9,12 +10,10 @@ process.argv
.reduce(
(files, file) =>
isGlob(file)
? Promise.all([
files,
glob(file, {
filesOnly: true,
}),
]).then(([files, matched]) => [...files, ...matched])
? Promise.all([files, glob(file)]).then(([files, matched]) => [
...files,
...matched,
])
: files.then(files => [...files, file]),
Promise.resolve<string[]>([]),
)
Expand Down
6 changes: 3 additions & 3 deletions packages/imagemin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'node:fs'
import fs from 'node:fs/promises'

import { Plugin } from 'imagemin'

Expand Down Expand Up @@ -57,10 +57,10 @@ const plugins = (
)

export default async (filename: string) =>
fs.promises.writeFile(
fs.writeFile(
filename,
await plugins.reduce(
async (acc, it) => (await it)(await acc),
fs.promises.readFile(filename),
fs.readFile(filename),
),
)
18 changes: 0 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6398,11 +6398,6 @@ globalthis@^1.0.3:
dependencies:
define-properties "^1.1.3"

globalyzer@0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/globalyzer/-/globalyzer-0.1.0.tgz#cb76da79555669a1519d5a8edf093afaa0bf1465"
integrity sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==

globby@10.0.1:
version "10.0.1"
resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.1.tgz#4782c34cb75dd683351335c5829cc3420e606b22"
Expand Down Expand Up @@ -6452,11 +6447,6 @@ globby@^13.1.3:
merge2 "^1.4.1"
slash "^4.0.0"

globrex@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/globrex/-/globrex-0.1.2.tgz#dd5d9ec826232730cd6793a5e33a9302985e6098"
integrity sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==

gopd@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c"
Expand Down Expand Up @@ -12118,14 +12108,6 @@ timers-ext@^0.1.7:
es5-ext "~0.10.46"
next-tick "1"

tiny-glob@^0.2.9:
version "0.2.9"
resolved "https://registry.yarnpkg.com/tiny-glob/-/tiny-glob-0.2.9.tgz#2212d441ac17928033b110f8b3640683129d31e2"
integrity sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==
dependencies:
globalyzer "0.1.0"
globrex "^0.1.2"

titleize@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/titleize/-/titleize-3.0.0.tgz#71c12eb7fdd2558aa8a44b0be83b8a76694acd53"
Expand Down

0 comments on commit 735e9ff

Please sign in to comment.