image-guard 5.2.3 → 5.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/NOTICE.md +7 -0
- package/README.md +7 -21
- package/bin/image-guard.sh +15 -0
- package/bin/image-guard.test.js +5 -5
- package/eslint.config.js +5 -3
- package/package.json +6 -5
- package/src/index.js +1 -1
- package/src/utils.js +1 -1
- package/NOTICE +0 -6
- /package/{LICENSE → LICENSE.md} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@ Starting with version 5.2.0, all notable changes to Image Guard are documented i
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and the project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [5.2.5] - 2026-03-17
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
* Added recommended ESLint rules to config (and fixed resulting warnings)
|
|
12
|
+
* Promoted `no-unused-vars` and `eqeqeq` from warnings to errors in ESLint config
|
|
13
|
+
|
|
14
|
+
## [5.2.4] - 2026-03-04
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
* Changed bin entry from a Node.js script to a shell wrapper that locates node from common version managers (nvm, Volta, asdf, mise) and package managers (Homebrew) before invocation, resolving hook failures in GUI Git clients that don’t inherit the shell’s PATH
|
|
19
|
+
- **Migration:** If you set up hooks, replace `npx image-guard --staged` with `./node_modules/.bin/image-guard --staged` in your `.githooks/pre-commit` or `.husky/pre-commit`.
|
|
20
|
+
|
|
7
21
|
## [5.2.3] - 2026-02-21
|
|
8
22
|
|
|
9
23
|
### Fixed
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Image Guard
|
|
2
|
+
|
|
3
|
+
Copyright 2022 [Jens Oliver Meiert](https://meiert.com/)
|
|
4
|
+
|
|
5
|
+
The initial developer of imagemin is [the imagemin team](https://github.com/orgs/imagemin/people).
|
|
6
|
+
|
|
7
|
+
The initial developer of imagemin-merlin (aka Merlin) is [sum.cumo](https://web.archive.org/web/20191208211414/https://www.sumcumo.com/). Copyright 2019 sum.cumo GmbH.
|
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ Native Git hooks are simpler to set up and don’t require additional dependenci
|
|
|
64
64
|
mkdir -p .githooks;\
|
|
65
65
|
cat > .githooks/pre-commit << 'EOF'
|
|
66
66
|
#!/bin/sh
|
|
67
|
-
|
|
67
|
+
./node_modules/.bin/image-guard --staged
|
|
68
68
|
EOF
|
|
69
69
|
chmod +x .githooks/pre-commit;\
|
|
70
70
|
git config core.hooksPath .githooks;\
|
|
@@ -72,7 +72,7 @@ git add .githooks/pre-commit;\
|
|
|
72
72
|
git commit -m "feat: add Git pre-commit hook for Image Guard";\
|
|
73
73
|
npm pkg set scripts.postprepare="mkdir -p .githooks && cat > .githooks/pre-commit << 'EOF'
|
|
74
74
|
#\!/bin/sh
|
|
75
|
-
|
|
75
|
+
./node_modules/.bin/image-guard --staged
|
|
76
76
|
EOF
|
|
77
77
|
chmod +x .githooks/pre-commit && git config core.hooksPath .githooks"
|
|
78
78
|
```
|
|
@@ -82,21 +82,21 @@ chmod +x .githooks/pre-commit && git config core.hooksPath .githooks"
|
|
|
82
82
|
If you already use [Husky](https://typicode.github.io/husky/), run the following commands in your project root (you can copy and execute them at once):
|
|
83
83
|
|
|
84
84
|
```console
|
|
85
|
-
grep -qxF "
|
|
85
|
+
grep -qxF "./node_modules/.bin/image-guard --staged" .husky/pre-commit || printf '\n./node_modules/.bin/image-guard --staged' >> .husky/pre-commit;\
|
|
86
86
|
git add .husky/pre-commit;\
|
|
87
87
|
git commit -m "feat: add Husky pre-commit hook for Image Guard";\
|
|
88
|
-
npm pkg set scripts.postprepare="grep -qxF '
|
|
88
|
+
npm pkg set scripts.postprepare="grep -qxF './node_modules/.bin/image-guard --staged' .husky/pre-commit || printf '\\n./node_modules/.bin/image-guard --staged' >> .husky/pre-commit"
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
If you don’t use Husky
|
|
91
|
+
If you don’t yet but want to use Husky, run the following commands from your project root:
|
|
92
92
|
|
|
93
93
|
```console
|
|
94
94
|
npm i -D husky;\
|
|
95
95
|
npx husky init;\
|
|
96
|
-
echo "
|
|
96
|
+
echo "./node_modules/.bin/image-guard --staged" > .husky/pre-commit;\
|
|
97
97
|
git add .husky/pre-commit;\
|
|
98
98
|
git commit -m "feat: add Husky pre-commit hook for Image Guard";\
|
|
99
|
-
npm pkg set scripts.postprepare="grep -qxF '
|
|
99
|
+
npm pkg set scripts.postprepare="grep -qxF './node_modules/.bin/image-guard --staged' .husky/pre-commit || printf '\\n./node_modules/.bin/image-guard --staged' >> .husky/pre-commit"
|
|
100
100
|
```
|
|
101
101
|
|
|
102
102
|
(The `postprepare` script ensures that the hook is added to the repository whenever someone installs the package.)
|
|
@@ -117,20 +117,6 @@ npm pkg set scripts.postprepare="grep -qxF 'npx image-guard --staged' .husky/pre
|
|
|
117
117
|
|
|
118
118
|
* `--quiet` suppresses per‑file logs and prints only the final summary (plus errors). This reduces console noise and speeds up runs in CI and Git hooks.
|
|
119
119
|
|
|
120
|
-
### Troubleshooting
|
|
121
|
-
|
|
122
|
-
#### “npx: command not found”
|
|
123
|
-
|
|
124
|
-
If Git hooks fail with “npx: command not found,” make sure to install (`npm i -D image-guard`) and to refer to the binary directly in the `pre-commit` hook (and, not detailed here, also in the `postprepare` script):
|
|
125
|
-
|
|
126
|
-
```console
|
|
127
|
-
#!/bin/sh
|
|
128
|
-
export PATH="$PWD/node_modules/.bin:$PATH"
|
|
129
|
-
./node_modules/.bin/image-guard --staged
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
This issue can arise in GUI Git clients (VS Code, GitHub Desktop, etc.) or with Node version managers, as these environments may not inherit your shell's `PATH`/Node environment. This affects any tool using npx in hooks.
|
|
133
|
-
|
|
134
120
|
## What Does the Output Look Like?
|
|
135
121
|
|
|
136
122
|
Roughly like this:
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
if ! command -v node > /dev/null 2>&1; then
|
|
3
|
+
[ -s "${NVM_DIR:-$HOME/.nvm}/nvm.sh" ] && . "${NVM_DIR:-$HOME/.nvm}/nvm.sh"
|
|
4
|
+
[ -d "$HOME/.volta/bin" ] && export PATH="$HOME/.volta/bin:$PATH"
|
|
5
|
+
[ -d "$HOME/.asdf/shims" ] && export PATH="$HOME/.asdf/shims:$PATH"
|
|
6
|
+
[ -d "$HOME/.local/share/mise/shims" ] && export PATH="$HOME/.local/share/mise/shims:$PATH"
|
|
7
|
+
[ -d "/opt/homebrew/bin" ] && export PATH="/opt/homebrew/bin:$PATH"
|
|
8
|
+
[ -d "/usr/local/bin" ] && export PATH="/usr/local/bin:$PATH"
|
|
9
|
+
[ -d "/home/linuxbrew/.linuxbrew/bin" ] && export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
|
|
10
|
+
fi
|
|
11
|
+
if ! command -v node > /dev/null 2>&1; then
|
|
12
|
+
echo "Image Guard: Node not found. Install Node.js via nvm, Volta, asdf, mise, or Homebrew." >&2
|
|
13
|
+
exit 1
|
|
14
|
+
fi
|
|
15
|
+
exec node "$(dirname "$0")/../image-guard/bin/image-guard.js" "$@"
|
package/bin/image-guard.test.js
CHANGED
|
@@ -305,7 +305,7 @@ describe('Image Guard', () => {
|
|
|
305
305
|
copyFiles(testFolder, tempTestFolder)
|
|
306
306
|
|
|
307
307
|
const originalCwd = process.cwd()
|
|
308
|
-
let stdout
|
|
308
|
+
let stdout
|
|
309
309
|
try {
|
|
310
310
|
process.chdir(tempDir)
|
|
311
311
|
stdout = execSync(`node "${imageGuardScript}" --quiet`, { encoding: 'utf8' })
|
|
@@ -333,7 +333,7 @@ describe('Image Guard', () => {
|
|
|
333
333
|
})
|
|
334
334
|
|
|
335
335
|
const originalCwd = process.cwd()
|
|
336
|
-
let stdout
|
|
336
|
+
let stdout
|
|
337
337
|
try {
|
|
338
338
|
process.chdir(tempDir)
|
|
339
339
|
stdout = execSync(`node "${imageGuardScript}" --dry --quiet`, { encoding: 'utf8' })
|
|
@@ -467,7 +467,7 @@ describe('Image Guard', () => {
|
|
|
467
467
|
const filesBefore = fs.readdirSync(tempTestFolder).sort()
|
|
468
468
|
|
|
469
469
|
const originalCwd = process.cwd()
|
|
470
|
-
let output
|
|
470
|
+
let output
|
|
471
471
|
try {
|
|
472
472
|
process.chdir(tempDir)
|
|
473
473
|
output = execSync(`node "${imageGuardScript}" --heic-to-avif --dry`, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] })
|
|
@@ -520,7 +520,7 @@ describe('Image Guard', () => {
|
|
|
520
520
|
copyFiles(testFolder, tempTestFolder)
|
|
521
521
|
|
|
522
522
|
const originalCwd = process.cwd()
|
|
523
|
-
let output
|
|
523
|
+
let output
|
|
524
524
|
try {
|
|
525
525
|
process.chdir(tempDir)
|
|
526
526
|
output = execSync(`node "${imageGuardScript}"`, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] })
|
|
@@ -538,7 +538,7 @@ describe('Image Guard', () => {
|
|
|
538
538
|
copyFiles(testFolder, tempTestFolder)
|
|
539
539
|
|
|
540
540
|
const originalCwd = process.cwd()
|
|
541
|
-
let output
|
|
541
|
+
let output
|
|
542
542
|
try {
|
|
543
543
|
process.chdir(tempDir)
|
|
544
544
|
output = execSync(`node "${imageGuardScript}" --keep-heic 2>&1`, { encoding: 'utf8' })
|
package/eslint.config.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
|
|
1
3
|
export default [
|
|
2
4
|
{
|
|
3
5
|
ignores: [
|
|
@@ -5,6 +7,7 @@ export default [
|
|
|
5
7
|
'node_modules/**'
|
|
6
8
|
]
|
|
7
9
|
},
|
|
10
|
+
js.configs.recommended,
|
|
8
11
|
{
|
|
9
12
|
languageOptions: {
|
|
10
13
|
ecmaVersion: 'latest',
|
|
@@ -17,9 +20,8 @@ export default [
|
|
|
17
20
|
},
|
|
18
21
|
rules: {
|
|
19
22
|
'no-console': 'off', // CLI tool—allow console
|
|
20
|
-
'no-
|
|
21
|
-
|
|
22
|
-
eqeqeq: ['warn', 'smart'],
|
|
23
|
+
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
24
|
+
eqeqeq: ['error', 'smart'],
|
|
23
25
|
curly: ['warn', 'multi-line']
|
|
24
26
|
}
|
|
25
27
|
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Jens Oliver Meiert",
|
|
3
3
|
"bin": {
|
|
4
|
-
"image-guard": "bin/image-guard.
|
|
5
|
-
"imagemin-guard": "bin/image-guard.
|
|
6
|
-
"imagemin-merlin": "bin/image-guard.
|
|
4
|
+
"image-guard": "bin/image-guard.sh",
|
|
5
|
+
"imagemin-guard": "bin/image-guard.sh",
|
|
6
|
+
"imagemin-merlin": "bin/image-guard.sh"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"globby": "^16.1.0",
|
|
10
10
|
"heic-decode": "^2.1.0",
|
|
11
11
|
"sharp": "^0.34.5",
|
|
12
|
-
"simple-git": "^3.
|
|
12
|
+
"simple-git": "^3.31.1"
|
|
13
13
|
},
|
|
14
14
|
"description": "Near-lossless image compressor that’s easy to use and easy to automate",
|
|
15
15
|
"devDependencies": {
|
|
16
|
+
"@eslint/js": "^10.0.0",
|
|
16
17
|
"eslint": "^10.0.0"
|
|
17
18
|
},
|
|
18
19
|
"funding": "https://github.com/j9t/image-guard?sponsor=1",
|
|
@@ -46,5 +47,5 @@
|
|
|
46
47
|
"test": "node --test bin/image-guard.test.js"
|
|
47
48
|
},
|
|
48
49
|
"type": "module",
|
|
49
|
-
"version": "5.2.
|
|
50
|
+
"version": "5.2.5"
|
|
50
51
|
}
|
package/src/index.js
CHANGED
package/src/utils.js
CHANGED
|
@@ -283,6 +283,6 @@ const size = async (file) => {
|
|
|
283
283
|
return stats.size
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
const sizeReadable = (size) => `${(size / 1024).toFixed(2)} KB`
|
|
286
|
+
const sizeReadable = (size) => `${(size / 1024).toFixed(2)} KB` // eslint-disable-line no-irregular-whitespace
|
|
287
287
|
|
|
288
288
|
export const utils = { compression, conversion, sizeReadable }
|
package/NOTICE
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
Image Guard
|
|
2
|
-
Copyright 2022 Jens Oliver Meiert (https://meiert.com/)
|
|
3
|
-
|
|
4
|
-
The initial developer of imagemin is the imagemin team (https://github.com/orgs/imagemin/people).
|
|
5
|
-
|
|
6
|
-
The initial developer of imagemin-merlin (aka Merlin) is sum.cumo (https://web.archive.org/web/20191208211414/https://www.sumcumo.com/). Copyright 2019 sum.cumo GmbH.
|
/package/{LICENSE → LICENSE.md}
RENAMED
|
File without changes
|