blob: 7260baa3dc424a2bb98a2c4cd4969e8091cf5e47 [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2const path = require('path');
3const binBuild = require('bin-build');
4const log = require('logalot');
5const bin = require('.');
6
7const args = [
8 '-copy',
9 'none',
10 '-optimize',
11 '-outfile',
12 path.join(__dirname, '../test/fixtures/test-optimized.jpg'),
13 path.join(__dirname, '../test/fixtures/test.jpg')
14];
15
16bin.run(args).then(() => {
17 log.success('jpegtran pre-build test passed successfully');
18}).catch(error => {
19 log.warn(error.message);
20 log.warn('jpegtran pre-build test failed');
21 log.info('compiling from source');
22
23 const cfg = [
24 './configure --disable-shared',
25 `--prefix="${bin.dest()}" --bindir="${bin.dest()}"`
26 ].join(' ');
27
28 binBuild.url('https://downloads.sourceforge.net/project/libjpeg-turbo/1.5.1/libjpeg-turbo-1.5.1.tar.gz', [
29 'touch configure.ac aclocal.m4 configure Makefile.am Makefile.in',
30 cfg,
31 'make install'
32 ]).then(() => {
33 log.success('jpegtran built successfully');
34 }).catch(error => {
35 log.error(error.stack);
36 });
37});