bin-wrapper
Advanced tools
+24
-7
@@ -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 @@ |
+22
-26
| { | ||
| "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" | ||
| } | ||
| } |
+24
-9
@@ -1,14 +0,16 @@ | ||
| # bin-wrapper [](http://travis-ci.org/kevva/bin-wrapper) | ||
| # bin-wrapper [](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) |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances 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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances 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
3.91%7
-12.5%262
6.5%115
15%5
-16.67%2
100%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated
Updated
Updated
Updated