Skip to content

Commit 0b871e0

Browse files
committed
Merge pull request #36 from shinnn/lazyrequire
Use lazy-req to require external modules lazily
2 parents 7860e3e + 4b54d37 commit 0b871e0

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

index.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
'use strict';
22

3-
var binCheck = require('bin-check');
4-
var binVersionCheck = require('bin-version-check');
5-
var Download = require('download');
63
var fs = require('fs');
7-
var osFilterObj = require('os-filter-obj');
4+
var lazyReq = require('lazy-req')(require);
85
var path = require('path');
96

7+
var binCheck = lazyReq('bin-check');
8+
var binVersionCheck = lazyReq('bin-version-check');
9+
var Download = lazyReq('download');
10+
var osFilterObj = lazyReq('os-filter-obj');
11+
1012
/**
1113
* Initialize a new `BinWrapper`
1214
*
@@ -143,7 +145,7 @@ BinWrapper.prototype.run = function (cmd, cb) {
143145
*/
144146

145147
BinWrapper.prototype.runCheck = function (cmd, cb) {
146-
binCheck(this.path(), cmd, function (err, works) {
148+
binCheck()(this.path(), cmd, function (err, works) {
147149
if (err) {
148150
cb(err);
149151
return;
@@ -155,7 +157,7 @@ BinWrapper.prototype.runCheck = function (cmd, cb) {
155157
}
156158

157159
if (this.version()) {
158-
return binVersionCheck(this.path(), this.version(), cb);
160+
return binVersionCheck()(this.path(), this.version(), cb);
159161
}
160162

161163
cb();
@@ -193,8 +195,8 @@ BinWrapper.prototype.findExisting = function (cb) {
193195
*/
194196

195197
BinWrapper.prototype.download = function (cb) {
196-
var files = osFilterObj(this.src());
197-
var download = new Download({
198+
var files = osFilterObj()(this.src());
199+
var download = new Download()({
198200
extract: true,
199201
mode: '755',
200202
strip: this.opts.strip

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"bin-version-check": "^2.1.0",
3030
"download": "^4.0.0",
3131
"each-async": "^1.1.1",
32+
"lazy-req": "^1.0.0",
3233
"os-filter-obj": "^1.0.0"
3334
},
3435
"devDependencies": {

0 commit comments

Comments
 (0)