bin-wrapper
Advanced tools
Comparing version 0.1.2 to 0.1.3
'use strict'; | ||
var download = require('download'); | ||
var exec = require('child_process').exec; | ||
var fs = require('fs'); | ||
var isbin = require('isbin'); | ||
var mout = require('mout'); | ||
var os = require('os'); | ||
var path = require('path'); | ||
@@ -26,3 +28,4 @@ var spawn = require('child_process').spawn; | ||
this.url = this.opts.url; | ||
this.source = this.opts.source; | ||
this.src = this.opts.src; | ||
this.buildScript = this.opts.buildScript; | ||
} | ||
@@ -63,2 +66,27 @@ | ||
BinWrapper.prototype.build = function (cb) { | ||
var self = this; | ||
var tmpDir = os.tmpdir ? os.tmpdir() : os.tmpDir(); | ||
var tmp = path.join(tmpDir, this.name); | ||
var get = download(this.src, tmp, { extract: true, strip: '1' }); | ||
if (!cb || !mout.lang.isFunction(cb)) { | ||
cb = function () {}; | ||
} | ||
if (!isbin('make')) { | ||
throw new Error('failed to find make'); | ||
} | ||
return get.on('close', function () { | ||
exec(self.buildScript, { cwd: tmp }, function (err) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
return cb(); | ||
}); | ||
}); | ||
}; | ||
/** | ||
@@ -65,0 +93,0 @@ * Test if a binary is working by checking its exit code |
{ | ||
"name": "bin-wrapper", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Binary wrapper for Node.js that makes your programs seamlessly available as local dependencies", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5610
129
2