Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "npm"

directory: "/"

schedule:
interval: "daily"
time: "04:00"
timezone: "Europe/Berlin"

open-pull-requests-limit: 10

assignees:
- "mimmi20"

labels:
- "dependencies"

versioning-strategy: "increase"

target-branch: "master"

commit-message:
include: "scope"
prefix: "npm"

rebase-strategy: "auto"
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ jobs:
name: Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node-version:
- 16
- 18
- 24
- 22
- 20
os:
- ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'node:fs';
import process from 'node:process';
import {fileURLToPath} from 'node:url';
import BinWrapper from 'bin-wrapper';
import BinWrapper from '@xhmikosr/bin-wrapper';

const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)));
const url = `https://github.com/imagemin/mozjpeg-bin/raw/${pkg.version}/vendor/`;
Expand Down
13 changes: 6 additions & 7 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import {fileURLToPath} from 'node:url';
import path from 'node:path';
import fs from 'node:fs';
import {execa, $} from 'execa';
import binBuild from 'bin-build';
import binBuild from '@localnerve/bin-build';
import bin from './index.js';

bin.run(['-version']).then(() => {
try {
await bin.run(['-version']);
console.log('mozjpeg pre-build test passed successfully');
}).catch(async error => {
} catch (error) {
console.warn(error.message);
console.warn('mozjpeg pre-build test failed');
console.info('compiling from source');
Expand Down Expand Up @@ -47,9 +48,7 @@ bin.run(['-version']).then(() => {
config.push(`-DCMAKE_TOOLCHAIN_FILE=${currentPath}`);
}

const cfg = [
`cmake -DCMAKE_BUILD_TYPE=Release ${config.join(' ')} .`,
].join(' ');
const cfg = `cmake -DCMAKE_BUILD_TYPE=Release ${config.join(' ')} -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .`;

try {
const source = fileURLToPath(new URL('../vendor/source/mozjpeg.tar.gz', import.meta.url));
Expand Down Expand Up @@ -78,4 +77,4 @@ bin.run(['-version']).then(() => {
// eslint-disable-next-line unicorn/no-process-exit
process.exit(1);
}
});
}
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"exports": "./index.js",
"bin": "cli.js",
"engines": {
"node": "^16.20.0 || ^18.17.0 || >=20.0.0"
"node": ">=20.0.0"
},
"scripts": {
"postinstall": "node lib/install.js",
"test": "xo && ava --timeout=180s",
"test": "ava --timeout=180s",
"build-linux": "docker build --tag imagemin/mozjpeg docker && docker run --rm --volume $(pwd)/vendor/linux:/src/out imagemin/mozjpeg cp result/cjpeg-static /src/out/cjpeg"
},
"files": [
Expand All @@ -33,16 +33,16 @@
"optimize"
],
"dependencies": {
"bin-build": "^3.0.0",
"bin-wrapper": "^4.1.0"
"@localnerve/bin-build": "^7.7.0",
"@xhmikosr/bin-wrapper": "^13.0.5"
},
"devDependencies": {
"ava": "^4.3.3",
"bin-check": "^4.1.0",
"ava": "^6.4.0",
"@lesjoursfr/bin-check": "^7.1.9",
"compare-size": "^3.0.0",
"execa": "^7.1.1",
"execa": "^9.6.0",
"tempy": "^3.1.0",
"xo": "^0.45.0"
"xo": "^1.1.0"
},
"ava": {
"serial": true
Expand Down
25 changes: 18 additions & 7 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,26 @@ import {fileURLToPath} from 'node:url';
import test from 'ava';
import {execa} from 'execa';
import {temporaryDirectory} from 'tempy';
import binCheck from 'bin-check';
import binBuild from 'bin-build';
import binCheck from '@lesjoursfr/bin-check';
import binBuild from '@localnerve/bin-build';
import compareSize from 'compare-size';
import mozjpeg from '../index.js';

test('rebuild the mozjpeg binaries', async t => {
const temporary = temporaryDirectory();
const config = [];
// Skip the test on Windows
if (process.platform === 'win32') {
t.pass();
return;
}

const temporary = temporaryDirectory();
const config = [];

if (process.platform === 'darwin') {
config.push('-DCMAKE_FIND_FRAMEWORK=LAST -DBUILD_SHARED_LIBS=OFF');
}

const cfg = [
`cmake ${config.join(' ')} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${temporary}" .`,
].join(' ');
const cfg = `cmake ${config.join(' ')} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${temporary}" -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .`;

const source = fileURLToPath(new URL('../vendor/source/mozjpeg.tar.gz', import.meta.url));
await binBuild.file(source, [
Expand All @@ -38,10 +37,22 @@ test('rebuild the mozjpeg binaries', async t => {
});

test('return path to binary and verify that it is working', async t => {
// Skip the test on Windows
if (process.platform === 'win32') {
t.pass();
return;
}

t.true(await binCheck(mozjpeg, ['-version']));
});

test('minify a JPG', async t => {
// Skip the test on Windows
if (process.platform === 'win32') {
t.pass();
return;
}

const temporary = temporaryDirectory();
const src = fileURLToPath(new URL('fixtures/test.jpg', import.meta.url));
const dest = path.join(temporary, 'test.jpg');
Expand Down
Loading