Skip to content

Binary wrapper for Node.js that makes your programs seamlessly available as local dependencies

License

Notifications You must be signed in to change notification settings

timothyklim/bin-wrapper

 
 

Repository files navigation

bin-wrapper Build Status

Binary wrapper for Node.js that makes your programs seamlessly available as local dependencies

Getting started

Install with npm: npm install bin-wrapper

Examples

All platform and arch specific options takes precedence over the base options. See test.js for a full fleshed example.

var Bin = require('bin-wrapper');

var opts = {
    name: 'Gifsicle',
    bin: 'gifsicle',
    path: 'vendor',
    url: 'http://url/to/gifsicle',
    src: 'http://www.lcdf.org/gifsicle/gifsicle-1.71.tar.gz',
    buildScript: './configure --bindir="vendor" && make install',
    platform: {
        win32: {
            bin: 'gifsicle.exe',
            url: [
                'http://url/to/gifsicle.exe'
                'http://url/to/gifsicle.dll'
            ]
        }
    }
}
var bin = new Bin(opts);

bin.check('--version', function (works) {
    if (!works) {
        console.log('Pre-build test failed, compiling from source');
        return bin.build();
    }

    console.log('Binary passed the test');
});

Get the path to your binary with bin.path.

console.log(bin.path);
// => path/to/vendor/gifsicle

API

.check(cmd, cb)

Check if a binary is present and working. If it isn't, download and test it by running the binary with cmd and see if it exits correctly.

.build(cb)

Download the source archive defined in the src property and build it using the build script defined in the buildScript property.

License

MIT License (c) Kevin Mårtensson

About

Binary wrapper for Node.js that makes your programs seamlessly available as local dependencies

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%