Skip to content

Commit

Permalink
Bundle sources in the package (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
farcop authored and sindresorhus committed May 25, 2019
1 parent 50d9673 commit 6bb7f1c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/install.js
@@ -1,4 +1,5 @@
'use strict';
const path = require('path');
const binBuild = require('bin-build');
const log = require('logalot');
const bin = require('.');
Expand All @@ -10,12 +11,16 @@ bin.run(['--version']).then(() => {
log.warn('optipng pre-build test failed');
log.info('compiling from source');

binBuild.url('https://downloads.sourceforge.net/project/optipng/OptiPNG/optipng-0.7.7/optipng-0.7.7.tar.gz', [
// From https://sourceforge.net/projects/optipng/files/OptiPNG/
binBuild.file(path.resolve(__dirname, '../vendor/source/optipng.tar.gz'), [
`./configure --with-system-zlib --prefix="${bin.dest()}" --bindir="${bin.dest()}"`,
'make install'
]).then(() => {
log.success('optipng built successfully');
}).catch(error => {
log.error(error.stack);

// eslint-disable-next-line unicorn/no-process-exit
process.exit(1);
});
});
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -33,7 +33,8 @@
"files": [
"index.js",
"cli.js",
"lib"
"lib",
"vendor/source"
],
"keywords": [
"imagemin",
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Expand Up @@ -18,7 +18,7 @@ test('rebuild the optipng binaries', async t => {

const tmp = tempy.directory();

await binBuild.url('http://downloads.sourceforge.net/project/optipng/OptiPNG/optipng-0.7.7/optipng-0.7.7.tar.gz', [
await binBuild.file(path.resolve(__dirname, '../vendor/source/optipng.tar.gz'), [
`./configure --with-system-zlib --prefix="${tmp}" --bindir="${tmp}"`,
'make install'
]);
Expand Down
Binary file added vendor/source/optipng.tar.gz
Binary file not shown.

0 comments on commit 6bb7f1c

Please sign in to comment.