pngquant-bin
Advanced tools
Comparing version 6.0.1 to 7.0.0
#!/usr/bin/env node | ||
'use strict'; | ||
const execa = require('execa'); | ||
const m = require('.'); | ||
import process from 'node:process'; | ||
import execa from 'execa'; | ||
import pngquant from './index.js'; | ||
execa(m, process.argv.slice(2), {stdio: 'inherit'}); | ||
execa(pngquant, process.argv.slice(2), {stdio: 'inherit'}); |
@@ -1,2 +0,3 @@ | ||
'use strict'; | ||
module.exports = require('./lib').path(); | ||
import lib from './lib/index.js'; | ||
export default lib.path(); |
@@ -1,9 +0,10 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const BinWrapper = require('bin-wrapper'); | ||
const pkg = require('../package.json'); | ||
import fs from 'node:fs'; | ||
import process from 'node:process'; | ||
import {fileURLToPath} from 'node:url'; | ||
import BinWrapper from 'bin-wrapper'; | ||
const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url))); | ||
const url = `https://raw.githubusercontent.com/imagemin/pngquant-bin/v${pkg.version}/vendor/`; | ||
module.exports = new BinWrapper() | ||
const binWrapper = new BinWrapper() | ||
.src(`${url}macos/pngquant`, 'darwin') | ||
@@ -14,3 +15,5 @@ .src(`${url}linux/x86/pngquant`, 'linux', 'x86') | ||
.src(`${url}win/pngquant.exe`, 'win32') | ||
.dest(path.resolve(__dirname, '../vendor')) | ||
.dest(fileURLToPath(new URL('../vendor', import.meta.url))) | ||
.use(process.platform === 'win32' ? 'pngquant.exe' : 'pngquant'); | ||
export default binWrapper; |
@@ -1,5 +0,5 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const binBuild = require('bin-build'); | ||
const bin = require('.'); | ||
import process from 'node:process'; | ||
import {fileURLToPath} from 'node:url'; | ||
import binBuild from 'bin-build'; | ||
import bin from './index.js'; | ||
@@ -16,6 +16,7 @@ bin.run(['--version']).then(() => { | ||
try { | ||
await binBuild.file(path.resolve(__dirname, '../vendor/source/pngquant.tar.gz'), [ | ||
const source = fileURLToPath(new URL('../vendor/source/pngquant.tar.gz', import.meta.url)); | ||
await binBuild.file(source, [ | ||
'rm ./INSTALL', | ||
`./configure --prefix="${bin.dest()}"`, | ||
`make install BINPREFIX="${bin.dest()}"` | ||
`make install BINPREFIX="${bin.dest()}"`, | ||
]); | ||
@@ -22,0 +23,0 @@ |
{ | ||
"name": "pngquant-bin", | ||
"version": "6.0.1", | ||
"version": "7.0.0", | ||
"description": "`pngquant` wrapper that makes it seamlessly available as a local dependency", | ||
"license": "GPL-3.0+", | ||
"repository": "imagemin/pngquant-bin", | ||
"type": "module", | ||
"author": { | ||
@@ -27,3 +28,3 @@ "name": "Kevin Mårtensson", | ||
"engines": { | ||
"node": ">=10" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
@@ -53,11 +54,11 @@ "scripts": { | ||
"bin-wrapper": "^4.0.1", | ||
"execa": "^4.0.0" | ||
"execa": "^5.1.1" | ||
}, | ||
"devDependencies": { | ||
"ava": "^3.8.0", | ||
"ava": "^3.15.0", | ||
"bin-check": "^4.0.1", | ||
"compare-size": "^3.0.0", | ||
"tempy": "^0.5.0", | ||
"xo": "^0.30.0" | ||
"tempy": "^2.0.0", | ||
"xo": "^0.45.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# pngquant-bin ![GitHub Actions Status](https://github.com/imagemin/pngquant-bin/workflows/test/badge.svg?branch=master) | ||
# pngquant-bin ![GitHub Actions Status](https://github.com/imagemin/pngquant-bin/workflows/test/badge.svg?branch=main) | ||
@@ -15,9 +15,19 @@ > [`pngquant`](https://github.com/kornelski/pngquant) is a PNG compressor that significantly reduces file sizes by converting images to a more efficient 8-bit PNG format | ||
Make sure you have the correct version of [libimagequant](https://github.com/ImageOptim/libimagequant). | ||
``` | ||
# via Homebrew for macOS | ||
$ brew install libimagequant | ||
# via apt-get for Debian distributions | ||
$ sudo apt-get install libimagequant-dev | ||
``` | ||
## Usage | ||
```js | ||
const {execFile} = require('child_process'); | ||
const pngquant = require('pngquant-bin'); | ||
import {execFile} from 'node:child_process'; | ||
import pngquant from 'pngquant-bin'; | ||
execFile(pngquant, ['-o', 'output.png', 'input.png'], err => { | ||
execFile(pngquant, ['-o', 'output.png', 'input.png'], error => { | ||
console.log('Image minified!'); | ||
@@ -24,0 +34,0 @@ }); |
Sorry, the diff of this file is not supported yet
48
55
Yes
111403
+ Addedexeca@5.1.1(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedhuman-signals@2.1.0(transitive)
- Removedexeca@4.1.0(transitive)
- Removedget-stream@5.2.0(transitive)
- Removedhuman-signals@1.1.1(transitive)
Updatedexeca@^5.1.1