| Leo Repp | 58b9f11 | 2021-11-22 11:57:47 +0100 | [diff] [blame^] | 1 | 'use strict'; |
| 2 | const path = require('path'); |
| 3 | const binBuild = require('bin-build'); |
| 4 | const log = require('logalot'); |
| 5 | const bin = require('.'); |
| 6 | |
| 7 | const 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 | |
| 16 | bin.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 | }); |