bin-wrapper
Advanced tools
Comparing version 0.2.3 to 0.2.4
31
index.js
@@ -8,3 +8,2 @@ 'use strict'; | ||
var findFile = require('find-file'); | ||
var fs = require('fs'); | ||
var merge = require('mout/object/merge'); | ||
@@ -24,2 +23,4 @@ var path = require('path'); | ||
* - `dest` Where to download the binary | ||
* - `version` Version of the binary | ||
* - `global` Whether to check for global binaries or not | ||
* | ||
@@ -33,2 +34,3 @@ * @param {Object} opts | ||
opts = opts || {}; | ||
this.opts = opts; | ||
this.bin = opts.bin; | ||
@@ -43,2 +45,3 @@ | ||
this.dest = opts.dest || process.cwd(); | ||
this.global = opts.global !== false; | ||
this.paths = [this.dest]; | ||
@@ -78,2 +81,4 @@ this.path = this._find(this.bin) || path.join(this.dest, this.bin); | ||
mode: '0755' | ||
}).once('data', function () { | ||
self.emit('download'); | ||
}).on('close', function () { | ||
@@ -215,9 +220,11 @@ return self._test(path.join(self.dest, self.bin), cmd); | ||
BinWrapper.prototype._find = function (bin) { | ||
var file = findFile(bin, { path: this.paths, exclude: 'node_modules/.bin' }); | ||
var opts = { path: this.paths, exclude: 'node_modules/.bin' }; | ||
if (!this.global) { | ||
opts.global = false; | ||
} | ||
var file = findFile(bin, opts); | ||
if (file) { | ||
if (fs.lstatSync(file[0]).isSymbolicLink()) { | ||
return false; | ||
} | ||
if (executable.sync(file[0])) { | ||
@@ -247,3 +254,13 @@ return file[0]; | ||
self.emit(works ? 'success' : 'fail'); | ||
if (self.opts.version && works) { | ||
binCheck(bin, '--version', function (err, works, msg) { | ||
if (msg) { | ||
self.emit(msg.indexOf(self.opts.version) !== -1 ? 'success' : 'fail'); | ||
} else { | ||
self.emit('success'); | ||
} | ||
}); | ||
} else { | ||
self.emit(works ? 'success' : 'fail'); | ||
} | ||
}); | ||
@@ -250,0 +267,0 @@ |
{ | ||
"name": "bin-wrapper", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Binary wrapper that makes your programs seamlessly available as local dependencies", | ||
"keywords": [ | ||
"bin", | ||
"build", | ||
"make", | ||
"wrapper" | ||
], | ||
"homepage": "https://github.com/kevva/bin-wrapper", | ||
"bugs": "https://github.com/kevva/bin-wrapper/issues", | ||
"license": "MIT", | ||
"repository": "kevva/bin-wrapper", | ||
"author": { | ||
"name": "Kevin Martensson", | ||
"name": "Kevin Mårtensson", | ||
"email": "kevinmartensson@gmail.com", | ||
"url": "http://kevinmartensson.com" | ||
"url": "https://github.com/kevva" | ||
}, | ||
"license": "MIT", | ||
"repository": "git://github.com/kevva/bin-wrapper.git", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "mocha --reporter list --timeout 0" | ||
}, | ||
"main": "index.js", | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"bin", | ||
"build", | ||
"make", | ||
"wrapper" | ||
], | ||
"dependencies": { | ||
"bin-check": "~0.1.0", | ||
"download": "~0.1.2", | ||
"executable": "~0.1.0", | ||
"find-file": "~0.1.2", | ||
"mout": "~0.9.0", | ||
"progress": "~1.1.0", | ||
"rimraf": "~2.2.6", | ||
"tempfile": "~0.1.2" | ||
"bin-check": "^0.1.0", | ||
"download": "^0.1.2", | ||
"executable": "^0.1.0", | ||
"find-file": "^0.1.2", | ||
"mout": "^0.9.1", | ||
"rimraf": "^2.2.6", | ||
"tempfile": "^0.1.2" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.17.0" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"mocha": "^1.18.2" | ||
} | ||
} |
@@ -1,14 +0,16 @@ | ||
# bin-wrapper [![Build Status](https://secure.travis-ci.org/kevva/bin-wrapper.png?branch=master)](http://travis-ci.org/kevva/bin-wrapper) | ||
# bin-wrapper [![Build Status](https://travis-ci.org/kevva/bin-wrapper.svg?branch=master)](https://travis-ci.org/kevva/bin-wrapper) | ||
Binary wrapper for Node.js that makes your programs seamlessly available as local dependencies | ||
> Binary wrapper for Node.js that makes your programs seamlessly available as local dependencies | ||
## Getting started | ||
## Install | ||
Install with [npm](https://npmjs.org/package/bin-wrapper): `npm install bin-wrapper` | ||
```bash | ||
$ npm install --save bin-wrapper | ||
``` | ||
## Examples | ||
## Usage | ||
```js | ||
var BinWrapper = require('bin-wrapper'); | ||
var bin = new BinWrapper({ bin: 'gifsicle', dest: 'vendor' }); | ||
var bin = new BinWrapper({ bin: 'gifsicle', version: '1.71', dest: 'vendor' }); | ||
@@ -18,3 +20,2 @@ bin | ||
.addUrl('https://raw.github.com/yeoman/node-gifsicle/0.1.4/vendor/linux/x64/gifsicle', 'linux', 'x64') | ||
.addFile('https://raw.github.com/yeoman/node-jpegtran-bin/master/vendor/win/x64/libjpeg-62.dll', 'windows', 'x64') | ||
.addSource('http://www.lcdf.org/gifsicle/gifsicle-1.71.tar.gz') | ||
@@ -36,3 +37,3 @@ .check() | ||
Get the path to your binary with `bin.path`. | ||
Get the path to your binary with `bin.path`: | ||
@@ -92,2 +93,16 @@ ```js | ||
### version | ||
Type: `String` | ||
Default: `undefined` | ||
Define a specific version. | ||
### global | ||
Type: `Boolean` | ||
Default: `true` | ||
Whether to check for a binary globally or not. | ||
### dest | ||
@@ -102,2 +117,2 @@ | ||
[MIT License](http://en.wikipedia.org/wiki/MIT_License) (c) [Kevin Mårtensson](http://kevinmartensson.com) | ||
[MIT License](http://en.wikipedia.org/wiki/MIT_License) © [Kevin Mårtensson](http://kevinmartensson.com) |
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
10372
7
262
115
5
2
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removedprogress@~1.1.0
- Removedprogress@1.1.8(transitive)
- Removedrimraf@2.2.8(transitive)
Updatedbin-check@^0.1.0
Updateddownload@^0.1.2
Updatedexecutable@^0.1.0
Updatedfind-file@^0.1.2
Updatedmout@^0.9.1
Updatedrimraf@^2.2.6
Updatedtempfile@^0.1.2