Skip to content
Browse files

checking for presence of make, passing in --bindir parameter in ./con…

…figure, added test
  • Loading branch information...
1 parent c5f1161 commit 82ccd0cabe78eccd6c840b2d69d2a308511dfb01 @badunk badunk committed Feb 17, 2013
View
4 .gitignore
@@ -1,2 +1,4 @@
+*.DS_Store
node_modules
-optipng/**
+optipng
+
View
3 package.json
@@ -27,7 +27,8 @@
"type": "BSD"
}],
"dependencies": {
- "colors": "~0.6.0"
+ "colors": "~0.6.0",
+ "which": "~1.0.5"
},
"devDependencies": {
"mocha": "~1.6.0"
View
25 rebuild-optipng.js
@@ -1,16 +1,29 @@
var exec = require('child_process').exec;
var colors = require('colors');
-var path = require('./lib/optipng-bin.js').path;
+var binPath = require('./lib/optipng-bin.js').path;
+var which = require('which');
+var path = require('path');
-if (process.platform === 'darwin' || process.platform === 'linux') {
- exec('make clean && ./configure && make && make test', {cwd: './optipng/', stdio: 'inherit'}, function(error, stdout, stderr) {
- exec('cp optipng/src/optipng/optipng ' + path, function(err){
+
+which('make', function(err, makepath){
+ if (err) {
+ console.log(err.red);
+ return;
+ }
+
+ if (process.platform === 'darwin' || process.platform === 'linux') {
+ var binDir = path.dirname(binPath);
+ var buildScript = 'make clean &&' +
+ './configure --with-system-zlib --bindir=' + binDir + ' --mandir=man && ' +
+ 'make install';
+ exec(buildScript, {cwd: './optipng/'}, function(error, stdout, stderr) {
if (err) {
console.log(err.red);
return;
}
console.log('OptiPNG rebuilt successfully'.green);
});
- });
-}
+ }
+});
+
View
19 test/test-optipng-build.js
@@ -0,0 +1,19 @@
+/*global describe, it, after */
+'use strict';
+
+var assert = require('assert');
+var exec = require('child_process').exec;
+var binPath = require('../lib/optipng-bin.js').path;
+var fs = require('fs');
+
+describe('OptiPNG rebuild', function() {
+ it('it should rebuild the optipng binaries', function(cb) {
+ this.timeout(15000); // give this test time to build
+ var origCTime = fs.statSync(binPath).ctime;
+ exec('node rebuild-optipng.js', {}, function(err){
+ var actualCTime = fs.statSync(binPath).ctime;
+ assert(actualCTime !== origCTime);
+ cb(err);
+ }).path;
+ });
+});
View
0 test/test-optipng-bin.js → test/test-optipng-path.js
File renamed without changes.

0 comments on commit 82ccd0c

Please sign in to comment.
Something went wrong with that request. Please try again.