Skip to content

Commit

Permalink
Require Node.js 18
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed May 5, 2024
1 parent 2a87c5e commit 44ee151
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 36 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ jobs:
fail-fast: false
matrix:
node-version:
- 16
- 14
- 12
- 22
- 18
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
23 changes: 11 additions & 12 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env node
import {Buffer} from 'node:buffer';
import process from 'node:process';
import arrify from 'arrify';
import meow from 'meow';
Expand All @@ -9,6 +8,7 @@ import ora from 'ora';
import plur from 'plur';
import stripIndent from 'strip-indent';
import pairs from 'lodash.pairs';
import {isUint8Array} from 'uint8array-extras';

const cli = meow(`
Usage
Expand All @@ -34,7 +34,7 @@ const cli = meow(`
flags: {
plugin: {
type: 'string',
alias: 'p',
shortFlag: 'p',
isMultiple: true,
default: [
'gifsicle',
Expand All @@ -45,14 +45,14 @@ const cli = meow(`
},
outDir: {
type: 'string',
alias: 'o',
shortFlag: 'o',
},
},
});

const requirePlugins = plugins => Promise.all(plugins.map(async ([plugin, options]) => {
try {
const {default: _plugin} = await import(`imagemin-${plugin}`); // eslint-disable-line node/no-unsupported-features/es-syntax
const {default: _plugin} = await import(`imagemin-${plugin}`);
return _plugin(options);
} catch {
console.error(stripIndent(`
Expand Down Expand Up @@ -88,7 +88,7 @@ const run = async (input, {outDir, plugin} = {}) => {
const plugins = await requirePlugins(pluginOptions);
const spinner = ora('Minifying images');

if (Buffer.isBuffer(input)) {
if (isUint8Array(input)) {
process.stdout.write(await imagemin.buffer(input, {plugins}));
return;
}
Expand Down Expand Up @@ -129,10 +129,9 @@ if (cli.input.length === 0 && process.stdin.isTTY) {
process.exit(1);
}

(async () => {
await run(
cli.input.length > 0
? cli.input
: await getStdin.buffer(),
cli.flags);
})();
await run(
cli.input.length > 0
? cli.input
: await getStdin.buffer(),
cli.flags,
);
33 changes: 18 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"description": "Minify images seamlessly",
"license": "MIT",
"repository": "imagemin/imagemin-cli",
"funding": "https://github.com/imagemin/imagemin-cli?sponsor=1",
"funding": "https://github.com/sponsors/sindresorhus",
"type": "module",
"bin": {
"imagemin": "cli.js"
"imagemin": "./cli.js"
},
"engines": {
"node": ">=12.20"
"node": ">=18"
},
"scripts": {
"test": "xo && ava"
Expand All @@ -34,30 +34,33 @@
"dependencies": {
"arrify": "^3.0.0",
"get-stdin": "^9.0.0",
"imagemin": "^8.0.0",
"imagemin": "^9.0.0",
"lodash.pairs": "^3.0.1",
"meow": "^10.1.1",
"ora": "^5.4.1",
"plur": "^4.0.0",
"strip-indent": "^4.0.0"
"meow": "^13.2.0",
"ora": "^8.0.1",
"plur": "^5.1.0",
"strip-indent": "^4.0.0",
"uint8array-extras": "^1.1.0"
},
"devDependencies": {
"ava": "^3.15.0",
"execa": "^5.1.1",
"ava": "^6.1.2",
"execa": "^8.0.1",
"imagemin-pngquant": "^9.0.2",
"typescript": "^4.3.5",
"xo": "^0.43.0"
"xo": "^0.58.0"
},
"optionalDependencies": {
"imagemin-gifsicle": "^7.0.0",
"imagemin-jpegtran": "^7.0.0",
"imagemin-optipng": "^8.0.0",
"imagemin-svgo": "^9.0.0"
"imagemin-svgo": "^10.0.1"
},
"ava": {
"workerThreads": false
},
"xo": {
"rules": {
"node/process-exit-as-throw": 2,
"node/no-unsupported-features": "off"
"n/process-exit-as-throw": 2,
"n/no-unsupported-features": "off"
}
}
}
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

## Install

```
$ npm install --global imagemin-cli
```sh
npm install --global imagemin-cli
```

## Usage
Expand Down
3 changes: 1 addition & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import fs from 'node:fs';
import {dirname} from 'node:path';
import {fileURLToPath} from 'node:url';
import process from 'node:process';

import execa from 'execa';
import {execa} from 'execa';
import test from 'ava';

const __dirname = dirname(fileURLToPath(import.meta.url));
Expand Down

0 comments on commit 44ee151

Please sign in to comment.