From 707aeb3ddf0268a57d617c7623956113f5f4df1e Mon Sep 17 00:00:00 2001 From: Shogo Sensui Date: Sun, 24 May 2020 17:51:15 +0900 Subject: [PATCH] Require Node.js 10 (#30) * Require Node.js 10 * Use util.promisify --- .travis.yml | 3 +-- package.json | 7 +++---- test.js | 22 +++++++++++----------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8a74f2e..a18175d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ os: - windows language: node_js node_js: + - '14' - '12' - '10' - - '8' - - '6' diff --git a/package.json b/package.json index 9cdef83..35aa7f3 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ } ], "engines": { - "node": ">=6" + "node": ">=10" }, "scripts": { "test": "xo && ava" @@ -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" } } diff --git a/test.js b/test.js index f4650da..3b08695 100644 --- a/test.js +++ b/test.js @@ -1,14 +1,14 @@ -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); @@ -16,13 +16,13 @@ test('convert an image into a WebP', async t => { }); 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/}); });