Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Node.js 10 #30

Merged
merged 2 commits into from
May 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ os:
- windows
language: node_js
node_js:
- '14'
- '12'
- '10'
- '8'
- '6'
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"engines": {
"node": ">=6"
"node": ">=10"
},
"scripts": {
"test": "xo && ava"
Expand All @@ -44,9 +44,8 @@
"is-cwebp-readable": "^3.0.0"
},
"devDependencies": {
"ava": "^0.25.0",
"ava": "^3.8.0",
"is-webp": "^1.0.0",
"pify": "^4.0.0",
"xo": "^0.23.0"
"xo": "^0.30.0"
}
}
22 changes: 11 additions & 11 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import fs from 'fs';
import path from 'path';
import isWebP from 'is-webp';
import pify from 'pify';
import test from 'ava';
import imageminWebp from '.';
const {promisify} = require('util');
const fs = require('fs');
const path = require('path');
const isWebP = require('is-webp');
const test = require('ava');
const imageminWebp = require('.');

const fsP = pify(fs);
const readFile = promisify(fs.readFile);

test('convert an image into a WebP', async t => {
const buf = await fsP.readFile(path.join(__dirname, 'fixtures/test.png'));
const buf = await readFile(path.join(__dirname, 'fixtures/test.png'));
const data = await imageminWebp()(buf);

t.true(data.length < buf.length);
t.true(isWebP(data));
});

test('skip optimizing unsupported files', async t => {
const buf = await fsP.readFile(path.join(__dirname, 'fixtures/test-unsupported.bmp'));
const buf = await readFile(path.join(__dirname, 'fixtures/test-unsupported.bmp'));
const data = await imageminWebp()(buf);

t.deepEqual(data, buf);
});

test('throw error when an image is corrupt', async t => {
const buf = await fsP.readFile(path.join(__dirname, 'fixtures/test-corrupt.webp'));
await t.throws(imageminWebp()(buf), /BITSTREAM_ERROR/);
const buf = await readFile(path.join(__dirname, 'fixtures/test-corrupt.webp'));
await t.throwsAsync(() => imageminWebp()(buf), {message: /BITSTREAM_ERROR/});
});