Skip to content

Commit

Permalink
Require Node.js 10 (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
1000ch authored May 29, 2020
1 parent 2b60e63 commit 49f230f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
sudo: false
language: node_js
node_js:
- '14'
- '12'
- '10'
- '8'
- '6'
addons:
apt:
packages: nasm
packages:
- nasm
18 changes: 10 additions & 8 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
});
}
});
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
14 changes: 7 additions & 7 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,36 @@ 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', [
cfg,
'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 => {
t.true(await binCheck(jpegtran, ['-version']));
});

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,
src
];

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]);
});

0 comments on commit 49f230f

Please sign in to comment.