optipng-bin
Advanced tools
Comparing version 7.0.1 to 8.0.0
#!/usr/bin/env node | ||
'use strict'; | ||
const {spawn} = require('child_process'); | ||
const optipng = require('.'); | ||
import {spawn} from 'node:child_process'; | ||
import process from 'node:process'; | ||
import optipng from './index.js'; | ||
@@ -6,0 +6,0 @@ const input = process.argv.slice(2); |
@@ -1,2 +0,3 @@ | ||
'use strict'; | ||
module.exports = require('./lib/index.js').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 packageJson = require('../package.json'); | ||
import fs from 'node:fs'; | ||
import process from 'node:process'; | ||
import {fileURLToPath} from 'node:url'; | ||
import BinWrapper from 'bin-wrapper'; | ||
const url = `https://raw.githubusercontent.com/imagemin/optipng-bin/v${packageJson.version}/vendor/`; | ||
const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url))); | ||
const url = `https://raw.githubusercontent.com/imagemin/optipng-bin/v${pkg.version}/vendor/`; | ||
module.exports = new BinWrapper() | ||
const binWrapper = new BinWrapper() | ||
.src(`${url}macos/optipng`, 'darwin') | ||
@@ -17,3 +18,5 @@ .src(`${url}linux/x86/optipng`, 'linux', 'x86') | ||
.src(`${url}win/optipng.exe`, 'win32') | ||
.dest(path.resolve(__dirname, '../vendor')) | ||
.dest(fileURLToPath(new URL('../vendor', import.meta.url))) | ||
.use(process.platform === 'win32' ? 'optipng.exe' : 'optipng'); | ||
export default binWrapper; |
@@ -1,5 +0,5 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const binBuild = require('bin-build'); | ||
const bin = require('./index.js'); | ||
import process from 'node:process'; | ||
import {fileURLToPath} from 'node:url'; | ||
import binBuild from 'bin-build'; | ||
import bin from './index.js'; | ||
@@ -16,6 +16,7 @@ (async () => { | ||
try { | ||
const source = fileURLToPath(new URL('../vendor/source/optipng.tar.gz', import.meta.url)); | ||
// From https://sourceforge.net/projects/optipng/files/OptiPNG/ | ||
await binBuild.file(path.resolve(__dirname, '../vendor/source/optipng.tar.gz'), [ | ||
await binBuild.file(source, [ | ||
`./configure --with-system-zlib --prefix="${bin.dest()}" --bindir="${bin.dest()}"`, | ||
'make install' | ||
'make install', | ||
]); | ||
@@ -22,0 +23,0 @@ |
{ | ||
"name": "optipng-bin", | ||
"version": "7.0.1", | ||
"version": "8.0.0", | ||
"description": "OptiPNG wrapper that makes it seamlessly available as a local dependency", | ||
"license": "MIT", | ||
"repository": "imagemin/optipng-bin", | ||
"type": "module", | ||
"bin": { | ||
@@ -11,3 +12,3 @@ "optipng": "cli.js" | ||
"engines": { | ||
"node": ">=10" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
@@ -41,6 +42,6 @@ "scripts": { | ||
"compare-size": "^3.0.0", | ||
"execa": "^5.0.0", | ||
"tempy": "^1.0.0", | ||
"xo": "^0.38.1" | ||
"execa": "^5.1.1", | ||
"tempy": "^2.0.0", | ||
"xo": "^0.45.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# optipng-bin ![GitHub Actions Status](https://github.com/imagemin/optipng-bin/workflows/test/badge.svg) | ||
# optipng-bin ![GitHub Actions Status](https://github.com/imagemin/optipng-bin/workflows/test/badge.svg?branch=main) | ||
@@ -18,12 +18,8 @@ > [OptiPNG](http://optipng.sourceforge.net) is a PNG optimizer that recompresses image files to a smaller size, without losing any information | ||
```js | ||
const {promisify} = require('util'); | ||
const {execFile} = require('child_process'); | ||
const optipng = require('optipng-bin'); | ||
import {execFile} from 'node:child_process'; | ||
import optipng from 'optipng-bin'; | ||
const execFileP = promsify(execFile); | ||
(async () => { | ||
await execFile(optipng, ['-out', 'output.png', 'input.png']); | ||
execFile(optipng, ['-out', 'output.png', 'input.png'], error => { | ||
console.log('Image minified!'); | ||
})(); | ||
}); | ||
``` | ||
@@ -30,0 +26,0 @@ |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
2334226
54
0
Yes
36