Skip to content

Commit

Permalink
Require Node.js 6 (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
1000ch authored and sindresorhus committed Dec 25, 2018
1 parent 62e5254 commit 2253cbc
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 41 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
sudo: false
language: node_js
node_js:
- '10'
- '8'
- '6'
- '4'
os:
- linux
- osx
Expand All @@ -16,4 +17,4 @@ addons:
- libpng-dev
before_install:
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then export CC=gcc-5 CXX=g++-5; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew update && brew upgrade libpng; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew upgrade libpng; fi
2 changes: 1 addition & 1 deletion cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
'use strict';
const spawn = require('child_process').spawn;
const {spawn} = require('child_process');
const guetzli = require('.');

const input = process.argv.slice(2);
Expand Down
37 changes: 15 additions & 22 deletions lib/install.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
'use strict';
const BinBuild = require('bin-build');
const binBuild = require('bin-build');
const log = require('logalot');
const bin = require('.');

bin.run(['--version'], err => {
if (err) {
log.warn(err.message);
log.warn('guetzli pre-build test failed');
log.info('compiling from source');

const builder = new BinBuild()
.src('https://github.com/google/guetzli/archive/v1.0.1.tar.gz')
.cmd(`mkdir -p ${bin.dest()}`)
.cmd(`make && mv bin/Release/${bin.use()} ${bin.path()}`);

return builder.run(err => {
if (err) {
log.error(err.stack);
return;
}

log.success('guetzli built successfully');
});
}

bin.run(['--verbose']).then(() => {
log.success('guetzli pre-build test passed successfully');
}).catch(error => {
log.warn(error.message);
log.warn('guetzli pre-build test failed');
log.info('compiling from source');

binBuild.url('https://github.com/google/guetzli/archive/v1.0.1.tar.gz', [
`mkdir -p ${bin.dest()}`,
`make && mv bin/Release/${bin.use()} ${bin.path()}`
]).then(() => {
log.success('guetzli built successfully');
}).catch(error => {
log.error(error.stack);
});
});
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"guetzli": "cli.js"
},
"engines": {
"node": ">=4"
"node": ">=6"
},
"scripts": {
"postinstall": "node lib/install.js",
Expand All @@ -36,17 +36,17 @@
"optimize"
],
"dependencies": {
"bin-build": "^2.2.0",
"bin-wrapper": "^3.0.2",
"bin-build": "^3.0.0",
"bin-wrapper": "^4.0.0",
"logalot": "^2.1.0"
},
"devDependencies": {
"ava": "*",
"bin-check": "^4.0.1",
"compare-size": "^3.0.0",
"execa": "^0.6.3",
"execa": "^1.0.0",
"executable": "^4.1.0",
"tempy": "^0.1.0",
"tempy": "^0.2.1",
"xo": "*"
}
}
19 changes: 8 additions & 11 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@ const test = require('ava');
const execa = require('execa');
const tempy = require('tempy');
const binCheck = require('bin-check');
const BinBuild = require('bin-build');
const binBuild = require('bin-build');
const compareSize = require('compare-size');
const executable = require('executable');
const guetzli = require('..');

test.cb('rebuild the guetzli binaries', t => {
test('rebuild the guetzli binaries', async t => {
const tmp = tempy.directory();

new BinBuild()
.src('https://github.com/google/guetzli/archive/v1.0.1.tar.gz')
.cmd(`mkdir -p ${tmp}`)
.cmd(`make && mv bin/Release/guetzli ${tmp}`)
.run(err => {
t.ifError(err);
t.true(executable.sync(path.join(tmp, 'guetzli')));
t.end();
});
await binBuild.url('https://github.com/google/guetzli/archive/v1.0.1.tar.gz', [
`mkdir -p ${tmp}`,
`make && mv bin/Release/guetzli ${tmp}`
]);

t.true(executable.sync(path.join(tmp, 'guetzli')));
});

test('return path to binary and verify that it is working', async t => {
Expand Down

0 comments on commit 2253cbc

Please sign in to comment.