pngcrush-bin
Advanced tools
Comparing version
#!/usr/bin/env node | ||
'use strict'; | ||
const {spawn} = require('child_process'); | ||
const pngcrush = require('.'); | ||
import {spawn} from 'node:child_process'; | ||
import process from 'node:process'; | ||
import pngcrush from './index.js'; | ||
@@ -6,0 +6,0 @@ const input = process.argv.slice(2); |
@@ -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/pngcrush-bin/v${pkg.version}/vendor/`; | ||
module.exports = new BinWrapper() | ||
const binWrapper = new BinWrapper() | ||
.src(`${url}osx/pngcrush`, 'darwin') | ||
@@ -13,3 +14,5 @@ .src(`${url}linux/pngcrush`, 'linux') | ||
.src(`${url}win/x86/pngcrush.exe`, 'win32', 'x86') | ||
.dest(path.resolve(__dirname, '../vendor')) | ||
.dest(fileURLToPath(new URL('../vendor', import.meta.url))) | ||
.use(process.platform === 'win32' ? 'pngcrush.exe' : 'pngcrush'); | ||
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'; | ||
@@ -14,5 +14,7 @@ bin.run(['-version']).then(() => { | ||
try { | ||
await binBuild.file(path.resolve(__dirname, '../vendor/source/pngcrush-1.8.13.tar.gz'), [ | ||
const source = fileURLToPath(new URL('../vendor/source/pngcrush-1.8.13.tar.gz', import.meta.url)); | ||
await binBuild.file(source, [ | ||
`mkdir -p ${bin.dest()}`, | ||
`make && mv ${bin.use()} ${bin.path()}` | ||
`make && mv ${bin.use()} ${bin.path()}`, | ||
]); | ||
@@ -19,0 +21,0 @@ |
{ | ||
"name": "pngcrush-bin", | ||
"version": "5.0.2", | ||
"version": "6.0.0", | ||
"description": "pngcrush wrapper that makes it seamlessly available as a local dependency", | ||
"license": "MIT", | ||
"repository": "imagemin/pngcrush-bin", | ||
"type": "module", | ||
"author": { | ||
"name": "1000ch", | ||
"name": "Shogo Sensui", | ||
"email": "shogo.sensui@gmail.com", | ||
@@ -32,3 +33,3 @@ "url": "github.com/1000ch" | ||
"engines": { | ||
"node": ">=10" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
@@ -62,9 +63,9 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^3.8.0", | ||
"ava": "^3.15.0", | ||
"bin-check": "^4.0.1", | ||
"compare-size": "^3.0.0", | ||
"execa": "^4.0.0", | ||
"tempy": "^0.5.0", | ||
"xo": "^0.30.0" | ||
"execa": "^5.1.1", | ||
"tempy": "^2.0.0", | ||
"xo": "^0.45.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# pngcrush-bin  | ||
# pngcrush-bin  | ||
@@ -18,6 +18,6 @@ > [pngcrush](https://pmt.sourceforge.io/pngcrush/) is an optimizer which main purpose is to reduce the size of the PNG IDAT datastream by trying various compression levels an PNG filter methods | ||
```js | ||
const {execFile} = require('child_process'); | ||
const pngcrush = require('pngcrush-bin'); | ||
import {execFile} from 'node:child_process'; | ||
import pngcrush from 'pngcrush-bin'; | ||
execFile(pngcrush, ['-reduce', '-brute', 'input.png', 'output.png'], err => { | ||
execFile(pngcrush, ['-reduce', '-brute', 'input.png', 'output.png'], error => { | ||
console.log('Image minified'); | ||
@@ -24,0 +24,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
566547
0.05%46
6.98%0
-100%Yes
NaN