first commit
This commit is contained in:
218
build/node_modules/bin-wrapper/index.js
generated
vendored
Normal file
218
build/node_modules/bin-wrapper/index.js
generated
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var lazyReq = require('lazy-req')(require);
|
||||
var binCheck = lazyReq('bin-check');
|
||||
var binVersionCheck = lazyReq('bin-version-check');
|
||||
var Download = lazyReq('download');
|
||||
var osFilterObj = lazyReq('os-filter-obj');
|
||||
|
||||
/**
|
||||
* Initialize a new `BinWrapper`
|
||||
*
|
||||
* @param {Object} opts
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function BinWrapper(opts) {
|
||||
if (!(this instanceof BinWrapper)) {
|
||||
return new BinWrapper(opts);
|
||||
}
|
||||
|
||||
this.opts = opts || {};
|
||||
this.opts.strip = this.opts.strip <= 0 ? 0 : !this.opts.strip ? 1 : this.opts.strip;
|
||||
}
|
||||
|
||||
module.exports = BinWrapper;
|
||||
|
||||
/**
|
||||
* Get or set files to download
|
||||
*
|
||||
* @param {String} src
|
||||
* @param {String} os
|
||||
* @param {String} arch
|
||||
* @api public
|
||||
*/
|
||||
|
||||
BinWrapper.prototype.src = function (src, os, arch) {
|
||||
if (!arguments.length) {
|
||||
return this._src;
|
||||
}
|
||||
|
||||
this._src = this._src || [];
|
||||
this._src.push({
|
||||
url: src,
|
||||
os: os,
|
||||
arch: arch
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get or set the destination
|
||||
*
|
||||
* @param {String} dest
|
||||
* @api public
|
||||
*/
|
||||
|
||||
BinWrapper.prototype.dest = function (dest) {
|
||||
if (!arguments.length) {
|
||||
return this._dest;
|
||||
}
|
||||
|
||||
this._dest = dest;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get or set the binary
|
||||
*
|
||||
* @param {String} bin
|
||||
* @api public
|
||||
*/
|
||||
|
||||
BinWrapper.prototype.use = function (bin) {
|
||||
if (!arguments.length) {
|
||||
return this._use;
|
||||
}
|
||||
|
||||
this._use = bin;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get or set a semver range to test the binary against
|
||||
*
|
||||
* @param {String} range
|
||||
* @api public
|
||||
*/
|
||||
|
||||
BinWrapper.prototype.version = function (range) {
|
||||
if (!arguments.length) {
|
||||
return this._version;
|
||||
}
|
||||
|
||||
this._version = range;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get path to the binary
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
BinWrapper.prototype.path = function () {
|
||||
return path.join(this.dest(), this.use());
|
||||
};
|
||||
|
||||
/**
|
||||
* Run
|
||||
*
|
||||
* @param {Array} cmd
|
||||
* @param {Function} cb
|
||||
* @api public
|
||||
*/
|
||||
|
||||
BinWrapper.prototype.run = function (cmd, cb) {
|
||||
if (typeof cmd === 'function' && !cb) {
|
||||
cb = cmd;
|
||||
cmd = ['--version'];
|
||||
}
|
||||
|
||||
this.findExisting(function (err) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.opts.skipCheck) {
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
|
||||
this.runCheck(cmd, cb);
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Run binary check
|
||||
*
|
||||
* @param {Array} cmd
|
||||
* @param {Function} cb
|
||||
* @api private
|
||||
*/
|
||||
|
||||
BinWrapper.prototype.runCheck = function (cmd, cb) {
|
||||
binCheck()(this.path(), cmd, function (err, works) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!works) {
|
||||
cb(new Error('The `' + this.path() + '` binary doesn\'t seem to work correctly'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.version()) {
|
||||
return binVersionCheck()(this.path(), this.version(), cb);
|
||||
}
|
||||
|
||||
cb();
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Find existing files
|
||||
*
|
||||
* @param {Function} cb
|
||||
* @api private
|
||||
*/
|
||||
|
||||
BinWrapper.prototype.findExisting = function (cb) {
|
||||
fs.stat(this.path(), function (err) {
|
||||
if (err && err.code === 'ENOENT') {
|
||||
this.download(cb);
|
||||
return;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
cb(err);
|
||||
return;
|
||||
}
|
||||
|
||||
cb();
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Download files
|
||||
*
|
||||
* @param {Function} cb
|
||||
* @api private
|
||||
*/
|
||||
|
||||
BinWrapper.prototype.download = function (cb) {
|
||||
var files = osFilterObj()(this.src());
|
||||
var download = new Download()({
|
||||
extract: true,
|
||||
mode: '755',
|
||||
strip: this.opts.strip
|
||||
});
|
||||
|
||||
if (!files.length) {
|
||||
cb(new Error('No binary found matching your system. It\'s probably not supported.'));
|
||||
return;
|
||||
}
|
||||
|
||||
files.forEach(function (file) {
|
||||
download.get(file.url);
|
||||
});
|
||||
|
||||
download
|
||||
.dest(this.dest())
|
||||
.run(cb);
|
||||
};
|
||||
21
build/node_modules/bin-wrapper/license
generated
vendored
Normal file
21
build/node_modules/bin-wrapper/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Kevin Mårtensson <kevinmartensson@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
78
build/node_modules/bin-wrapper/package.json
generated
vendored
Normal file
78
build/node_modules/bin-wrapper/package.json
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"bin-wrapper@3.0.2",
|
||||
"/Users/asciidisco/Desktop/asciidisco.com/build"
|
||||
]
|
||||
],
|
||||
"_from": "bin-wrapper@3.0.2",
|
||||
"_id": "bin-wrapper@3.0.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-Z9MwYmLksaXy+I7iNGT2plVneus=",
|
||||
"_location": "/bin-wrapper",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "bin-wrapper@3.0.2",
|
||||
"name": "bin-wrapper",
|
||||
"escapedName": "bin-wrapper",
|
||||
"rawSpec": "3.0.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "3.0.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jpeg-recompress-bin",
|
||||
"/jpegoptim-bin",
|
||||
"/jpegtran-bin",
|
||||
"/mozjpeg"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/bin-wrapper/-/bin-wrapper-3.0.2.tgz",
|
||||
"_spec": "3.0.2",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build",
|
||||
"author": {
|
||||
"name": "Kevin Mårtensson",
|
||||
"email": "kevinmartensson@gmail.com",
|
||||
"url": "https://github.com/kevva"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/kevva/bin-wrapper/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"bin-check": "^2.0.0",
|
||||
"bin-version-check": "^2.1.0",
|
||||
"download": "^4.0.0",
|
||||
"each-async": "^1.1.1",
|
||||
"lazy-req": "^1.0.0",
|
||||
"os-filter-obj": "^1.0.0"
|
||||
},
|
||||
"description": "Binary wrapper that makes your programs seamlessly available as local dependencies",
|
||||
"devDependencies": {
|
||||
"ava": "^0.0.4",
|
||||
"nock": "^2.6.0",
|
||||
"rimraf": "^2.2.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/kevva/bin-wrapper#readme",
|
||||
"keywords": [
|
||||
"bin",
|
||||
"check",
|
||||
"local",
|
||||
"wrapper"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "bin-wrapper",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/kevva/bin-wrapper.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/test.js"
|
||||
},
|
||||
"version": "3.0.2"
|
||||
}
|
||||
132
build/node_modules/bin-wrapper/readme.md
generated
vendored
Normal file
132
build/node_modules/bin-wrapper/readme.md
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
# bin-wrapper [](https://travis-ci.org/kevva/bin-wrapper)
|
||||
|
||||
> Binary wrapper that makes your programs seamlessly available as local dependencies
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save bin-wrapper
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var BinWrapper = require('bin-wrapper');
|
||||
|
||||
var base = 'https://github.com/imagemin/gifsicle-bin/raw/master/vendor';
|
||||
var bin = new BinWrapper()
|
||||
.src(base + '/osx/gifsicle', 'darwin')
|
||||
.src(base + '/linux/x64/gifsicle', 'linux', 'x64')
|
||||
.src(base + '/win/x64/gifsicle.exe', 'win32', 'x64')
|
||||
.dest(path.join('vendor'))
|
||||
.use(process.platform === 'win32' ? 'gifsicle.exe' : 'gifsicle')
|
||||
.version('>=1.71');
|
||||
|
||||
bin.run(['--version'], function (err) {
|
||||
console.log('gifsicle is working');
|
||||
});
|
||||
```
|
||||
|
||||
Get the path to your binary with `bin.path()`:
|
||||
|
||||
```js
|
||||
console.log(bin.path()); // => path/to/vendor/gifsicle
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### new BinWrapper(options)
|
||||
|
||||
Creates a new `BinWrapper` instance.
|
||||
|
||||
#### options.skipCheck
|
||||
|
||||
Type: `boolean`
|
||||
Default: `false`
|
||||
|
||||
Whether to skip the binary check or not.
|
||||
|
||||
#### options.strip
|
||||
|
||||
Type: `number`
|
||||
Default: `1`
|
||||
|
||||
Strip a number of leading paths from file names on extraction.
|
||||
|
||||
### .src(url, [os], [arch])
|
||||
|
||||
Adds a source to download.
|
||||
|
||||
#### url
|
||||
|
||||
Type: `string`
|
||||
|
||||
Accepts a URL pointing to a file to download.
|
||||
|
||||
#### os
|
||||
|
||||
Type: `string`
|
||||
|
||||
Tie the source to a specific OS.
|
||||
|
||||
#### arch
|
||||
|
||||
Type: `string`
|
||||
|
||||
Tie the source to a specific arch.
|
||||
|
||||
### .dest(dest)
|
||||
|
||||
#### dest
|
||||
|
||||
Type: `string`
|
||||
|
||||
Accepts a path which the files will be downloaded to.
|
||||
|
||||
### .use(bin)
|
||||
|
||||
#### bin
|
||||
|
||||
Type: `string`
|
||||
|
||||
Define which file to use as the binary.
|
||||
|
||||
### .path()
|
||||
|
||||
Returns the full path to your binary.
|
||||
|
||||
### .version(range)
|
||||
|
||||
#### range
|
||||
|
||||
Type: `string`
|
||||
|
||||
Define a [semver range](https://github.com/isaacs/node-semver#ranges) to check
|
||||
the binary against.
|
||||
|
||||
### .run([cmd], callback)
|
||||
|
||||
Runs the search for the binary. If no binary is found it will download the file
|
||||
using the URL provided in `.src()`.
|
||||
|
||||
#### cmd
|
||||
|
||||
Type: `array`
|
||||
Default: `['--version']`
|
||||
|
||||
Command to run the binary with. If it exits with code `0` it means that the
|
||||
binary is working.
|
||||
|
||||
#### callback(err)
|
||||
|
||||
Type: `function`
|
||||
|
||||
Returns nothing but a possible error.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Kevin Mårtensson](http://kevinmartensson.com)
|
||||
Reference in New Issue
Block a user