jpegtran-bin
Advanced tools
Comparing version 5.0.2 to 6.0.0
#!/usr/bin/env node | ||
'use strict'; | ||
const {spawn} = require('child_process'); | ||
const jpegtran = require('.'); | ||
import {spawn} from 'node:child_process'; | ||
import process from 'node:process'; | ||
import jpegtran 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/jpegtran-bin/v${pkg.version}/vendor/`; | ||
module.exports = new BinWrapper() | ||
const binWrapper = new BinWrapper() | ||
.src(`${url}macos/jpegtran`, 'darwin') | ||
@@ -20,3 +21,5 @@ .src(`${url}linux/x86/jpegtran`, 'linux', 'x86') | ||
.src(`${url}win/x64/libjpeg-62.dll`, 'win32', 'x64') | ||
.dest(path.join(__dirname, '../vendor')) | ||
.dest(fileURLToPath(new URL('../vendor', import.meta.url))) | ||
.use(process.platform === 'win32' ? 'jpegtran.exe' : 'jpegtran'); | ||
export default binWrapper; |
@@ -1,6 +0,5 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const binBuild = require('bin-build'); | ||
const log = require('logalot'); | ||
const bin = require('.'); | ||
import process from 'node:process'; | ||
import {fileURLToPath} from 'node:url'; | ||
import binBuild from 'bin-build'; | ||
import bin from './index.js'; | ||
@@ -12,28 +11,29 @@ const args = [ | ||
'-outfile', | ||
path.join(__dirname, '../test/fixtures/test-optimized.jpg'), | ||
path.join(__dirname, '../test/fixtures/test.jpg') | ||
fileURLToPath(new URL('../test/fixtures/test-optimized.jpg', import.meta.url)), | ||
fileURLToPath(new URL('../test/fixtures/test.jpg', import.meta.url)), | ||
]; | ||
bin.run(args).then(() => { | ||
log.success('jpegtran pre-build test passed successfully'); | ||
console.log('jpegtran pre-build test passed successfully'); | ||
}).catch(async error => { | ||
log.warn(error.message); | ||
log.warn('jpegtran pre-build test failed'); | ||
log.info('compiling from source'); | ||
console.warn(error.message); | ||
console.warn('jpegtran pre-build test failed'); | ||
console.info('compiling from source'); | ||
const cfg = [ | ||
'./configure --disable-shared', | ||
`--prefix="${bin.dest()}" --bindir="${bin.dest()}"` | ||
`--prefix="${bin.dest()}" --bindir="${bin.dest()}"`, | ||
].join(' '); | ||
try { | ||
await binBuild.file(path.resolve(__dirname, '../vendor/source/libjpeg-turbo-1.5.1.tar.gz'), [ | ||
const source = fileURLToPath(new URL('../vendor/source/libjpeg-turbo-1.5.1.tar.gz', import.meta.url)); | ||
await binBuild.file(source, [ | ||
'touch configure.ac aclocal.m4 configure Makefile.am Makefile.in', | ||
cfg, | ||
'make install' | ||
'make install', | ||
]); | ||
log.success('jpegtran built successfully'); | ||
console.log('jpegtran built successfully'); | ||
} catch (error) { | ||
log.error(error.stack); | ||
console.error(error.stack); | ||
@@ -40,0 +40,0 @@ // eslint-disable-next-line unicorn/no-process-exit |
{ | ||
"name": "jpegtran-bin", | ||
"version": "5.0.2", | ||
"version": "6.0.0", | ||
"description": "jpegtran (part of libjpeg-turbo) bin-wrapper that makes it seamlessly available as a local dependency", | ||
"license": "MIT", | ||
"repository": "imagemin/jpegtran-bin", | ||
"type": "module", | ||
"author": { | ||
@@ -27,7 +28,7 @@ "name": "Sindre Sorhus", | ||
"engines": { | ||
"node": ">=10" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
"scripts": { | ||
"postinstall": "node lib/install.js", | ||
"test": "xo && ava --timeout=120s" | ||
"test": "xo && ava --timeout=180s" | ||
}, | ||
@@ -54,13 +55,12 @@ "files": [ | ||
"bin-build": "^3.0.0", | ||
"bin-wrapper": "^4.0.0", | ||
"logalot": "^2.0.0" | ||
"bin-wrapper": "^4.0.0" | ||
}, | ||
"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 @@ | ||
# jpegtran-bin [![Build Status](https://travis-ci.org/imagemin/jpegtran-bin.svg?branch=master)](https://travis-ci.org/imagemin/jpegtran-bin) | ||
# jpegtran-bin ![GitHub Actions Status](https://github.com/imagemin/jpegtran-bin/workflows/test/badge.svg?branch=main) | ||
@@ -18,4 +18,4 @@ > [libjpeg-turbo](http://libjpeg-turbo.virtualgl.org/) is a derivative of libjpeg that uses SIMD instructions (MMX, SSE2, NEON) to accelerate baseline JPEG compression and decompression on x86, x86-64, and ARM systems. On such systems, libjpeg-turbo is generally 2-4x as fast as the unmodified version of libjpeg, all else being equal. | ||
```js | ||
const {execFile} = require('child_process'); | ||
const jpegtran = require('jpegtran-bin'); | ||
import {execFile} from 'node:child_process'; | ||
import jpegtran from 'jpegtran-bin'; | ||
@@ -22,0 +22,0 @@ execFile(jpegtran, ['-outfile', 'output.jpg', 'input.jpg'], error => { |
@@ -1,22 +0,30 @@ | ||
'use strict'; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const test = require('ava'); | ||
const execa = require('execa'); | ||
const tempy = require('tempy'); | ||
const binCheck = require('bin-check'); | ||
const binBuild = require('bin-build'); | ||
const compareSize = require('compare-size'); | ||
const jpegtran = require('..'); | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import process from 'node:process'; | ||
import {fileURLToPath} from 'node:url'; | ||
import test from 'ava'; | ||
import execa from 'execa'; | ||
import tempy from 'tempy'; | ||
import binCheck from 'bin-check'; | ||
import binBuild from 'bin-build'; | ||
import compareSize from 'compare-size'; | ||
import jpegtran from '../index.js'; | ||
test('rebuild the jpegtran binaries', async t => { | ||
// Skip the test on Windows | ||
if (process.platform === 'win32') { | ||
t.pass(); | ||
return; | ||
} | ||
const temporary = tempy.directory(); | ||
const cfg = [ | ||
'./configure --disable-shared', | ||
`--prefix="${temporary}" --bindir="${temporary}"` | ||
`--prefix="${temporary}" --bindir="${temporary}"`, | ||
].join(' '); | ||
const source = fileURLToPath(new URL('../vendor/source/libjpeg-turbo-1.5.1.tar.gz', import.meta.url)); | ||
await binBuild.file(path.resolve(__dirname, '../vendor/source/libjpeg-turbo-1.5.1.tar.gz'), [ | ||
await binBuild.file(source, [ | ||
cfg, | ||
'make install' | ||
'make install', | ||
]); | ||
@@ -33,3 +41,3 @@ | ||
const temporary = tempy.directory(); | ||
const src = path.join(__dirname, 'fixtures/test.jpg'); | ||
const src = fileURLToPath(new URL('fixtures/test.jpg', import.meta.url)); | ||
const dest = path.join(temporary, 'test.jpg'); | ||
@@ -39,3 +47,3 @@ const args = [ | ||
dest, | ||
src | ||
src, | ||
]; | ||
@@ -42,0 +50,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1660933
2
111
1
0
Yes
- Removedlogalot@^2.0.0
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedarray-find-index@1.0.2(transitive)
- Removedcamelcase@2.1.1(transitive)
- Removedcamelcase-keys@2.1.0(transitive)
- Removedchalk@1.1.3(transitive)
- Removedconsole-stream@0.1.1(transitive)
- Removedcurrently-unhandled@0.4.1(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedfigures@1.7.0(transitive)
- Removedfind-up@1.1.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-stdin@4.0.1(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedindent-string@2.1.0(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-finite@1.1.0(transitive)
- Removedis-utf8@0.2.1(transitive)
- Removedload-json-file@1.1.0(transitive)
- Removedlogalot@2.1.0(transitive)
- Removedlongest@1.0.1(transitive)
- Removedloud-rejection@1.6.0(transitive)
- Removedlpad-align@1.1.2(transitive)
- Removedmap-obj@1.0.1(transitive)
- Removedmeow@3.7.0(transitive)
- Removedminimist@1.2.8(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removedparse-json@2.2.0(transitive)
- Removedpath-exists@2.1.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@1.1.0(transitive)
- Removedread-pkg@1.1.0(transitive)
- Removedread-pkg-up@1.0.1(transitive)
- Removedredent@1.0.0(transitive)
- Removedrepeating@2.0.1(transitive)
- Removedresolve@1.22.8(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.20(transitive)
- Removedsqueak@1.3.0(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedstrip-bom@2.0.0(transitive)
- Removedstrip-indent@1.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedtrim-newlines@1.0.0(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)