From 49f230ffbf6160955e3e11150995bafd0135e31f Mon Sep 17 00:00:00 2001 From: Shogo Sensui Date: Fri, 29 May 2020 19:37:30 +0900 Subject: [PATCH] Require Node.js 10 (#97) --- .travis.yml | 7 ++++--- lib/install.js | 18 ++++++++++-------- package.json | 12 ++++++------ test/test.js | 14 +++++++------- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index ea1976b..180cd69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ sudo: false language: node_js node_js: + - '14' + - '12' - '10' - - '8' - - '6' addons: apt: - packages: nasm + packages: + - nasm diff --git a/lib/install.js b/lib/install.js index cbc94ff..08c847d 100644 --- a/lib/install.js +++ b/lib/install.js @@ -15,7 +15,7 @@ const args = [ bin.run(args).then(() => { log.success('jpegtran pre-build test passed successfully'); -}).catch(error => { +}).catch(async error => { log.warn(error.message); log.warn('jpegtran pre-build test failed'); log.info('compiling from source'); @@ -25,13 +25,15 @@ bin.run(args).then(() => { `--prefix="${bin.dest()}" --bindir="${bin.dest()}"` ].join(' '); - binBuild.file(path.resolve(__dirname, '../vendor/source/libjpeg-turbo-1.5.1.tar.gz'), [ - 'touch configure.ac aclocal.m4 configure Makefile.am Makefile.in', - cfg, - 'make install' - ]).then(() => { + try { + await binBuild.file(path.resolve(__dirname, '../vendor/source/libjpeg-turbo-1.5.1.tar.gz'), [ + 'touch configure.ac aclocal.m4 configure Makefile.am Makefile.in', + cfg, + 'make install' + ]); + log.success('jpegtran built successfully'); - }).catch(error => { + } catch (error) { log.error(error.stack); - }); + } }); diff --git a/package.json b/package.json index 8987edc..60fa6b4 100644 --- a/package.json +++ b/package.json @@ -24,11 +24,11 @@ "jpegtran": "cli.js" }, "engines": { - "node": ">=6" + "node": ">=10" }, "scripts": { "postinstall": "node lib/install.js", - "test": "xo && ava" + "test": "xo && ava --timeout=120s" }, "files": [ "index.js", @@ -53,11 +53,11 @@ "logalot": "^2.0.0" }, "devDependencies": { - "ava": "*", + "ava": "^3.8.0", "bin-check": "^4.0.1", "compare-size": "^3.0.0", - "execa": "^1.0.0", - "tempy": "^0.2.1", - "xo": "*" + "execa": "^4.0.0", + "tempy": "^0.5.0", + "xo": "^0.30.0" } } diff --git a/test/test.js b/test/test.js index 95754be..c4e75a3 100644 --- a/test/test.js +++ b/test/test.js @@ -10,10 +10,10 @@ const compareSize = require('compare-size'); const jpegtran = require('..'); test('rebuild the jpegtran binaries', async t => { - const tmp = tempy.directory(); + const temporary = tempy.directory(); const cfg = [ './configure --disable-shared', - `--prefix="${tmp}" --bindir="${tmp}"` + `--prefix="${temporary}" --bindir="${temporary}"` ].join(' '); await binBuild.url('https://downloads.sourceforge.net/project/libjpeg-turbo/1.5.1/libjpeg-turbo-1.5.1.tar.gz', [ @@ -21,7 +21,7 @@ test('rebuild the jpegtran binaries', async t => { 'make install' ]); - t.true(fs.existsSync(path.join(tmp, 'jpegtran'))); + t.true(fs.existsSync(path.join(temporary, 'jpegtran'))); }); test('return path to binary and verify that it is working', async t => { @@ -29,9 +29,9 @@ test('return path to binary and verify that it is working', async t => { }); test('minify a JPG', async t => { - const tmp = tempy.directory(); + const temporary = tempy.directory(); const src = path.join(__dirname, 'fixtures/test.jpg'); - const dest = path.join(tmp, 'test.jpg'); + const dest = path.join(temporary, 'test.jpg'); const args = [ '-outfile', dest, @@ -39,7 +39,7 @@ test('minify a JPG', async t => { ]; await execa(jpegtran, args); - const res = await compareSize(src, dest); + const result = await compareSize(src, dest); - t.true(res[dest] < res[src]); + t.true(result[dest] < result[src]); });