11'use strict' ;
2- var fs = require ( 'fs' ) ;
3- var path = require ( 'path' ) ;
4- var lazyReq = require ( 'lazy-req' ) ( require ) ;
5- var binCheck = lazyReq ( 'bin-check' ) ;
6- var binVersionCheck = lazyReq ( 'bin-version-check' ) ;
7- var Download = lazyReq ( 'download' ) ;
8- var osFilterObj = lazyReq ( 'os-filter-obj' ) ;
2+ const fs = require ( 'fs' ) ;
3+ const path = require ( 'path' ) ;
4+ const importLazy = require ( 'import-lazy' ) ( require ) ;
5+
6+ const binCheck = importLazy ( 'bin-check' ) ;
7+ const binVersionCheck = importLazy ( 'bin-version-check' ) ;
8+ const Download = importLazy ( 'download' ) ;
9+ const osFilterObj = importLazy ( 'os-filter-obj' ) ;
910
1011/**
1112 * Initialize a new `BinWrapper`
@@ -40,15 +41,15 @@ module.exports = BinWrapper;
4041 */
4142
4243BinWrapper . prototype . src = function ( src , os , arch ) {
43- if ( ! arguments . length ) {
44+ if ( arguments . length === 0 ) {
4445 return this . _src ;
4546 }
4647
4748 this . _src = this . _src || [ ] ;
4849 this . _src . push ( {
4950 url : src ,
50- os : os ,
51- arch : arch
51+ os,
52+ arch
5253 } ) ;
5354
5455 return this ;
@@ -62,7 +63,7 @@ BinWrapper.prototype.src = function (src, os, arch) {
6263 */
6364
6465BinWrapper . prototype . dest = function ( dest ) {
65- if ( ! arguments . length ) {
66+ if ( arguments . length === 0 ) {
6667 return this . _dest ;
6768 }
6869
@@ -78,7 +79,7 @@ BinWrapper.prototype.dest = function (dest) {
7879 */
7980
8081BinWrapper . prototype . use = function ( bin ) {
81- if ( ! arguments . length ) {
82+ if ( arguments . length === 0 ) {
8283 return this . _use ;
8384 }
8485
@@ -94,7 +95,7 @@ BinWrapper.prototype.use = function (bin) {
9495 */
9596
9697BinWrapper . prototype . version = function ( range ) {
97- if ( ! arguments . length ) {
98+ if ( arguments . length === 0 ) {
9899 return this . _version ;
99100 }
100101
@@ -126,7 +127,7 @@ BinWrapper.prototype.run = function (cmd, cb) {
126127 cmd = [ '--version' ] ;
127128 }
128129
129- this . findExisting ( function ( err ) {
130+ this . findExisting ( err => {
130131 if ( err ) {
131132 cb ( err ) ;
132133 return ;
@@ -138,7 +139,7 @@ BinWrapper.prototype.run = function (cmd, cb) {
138139 }
139140
140141 this . runCheck ( cmd , cb ) ;
141- } . bind ( this ) ) ;
142+ } ) ;
142143} ;
143144
144145/**
@@ -150,7 +151,7 @@ BinWrapper.prototype.run = function (cmd, cb) {
150151 */
151152
152153BinWrapper . prototype . runCheck = function ( cmd , cb ) {
153- binCheck ( ) ( this . path ( ) , cmd , function ( err , works ) {
154+ binCheck ( ) ( this . path ( ) , cmd , ( err , works ) => {
154155 if ( err ) {
155156 cb ( err ) ;
156157 return ;
@@ -167,7 +168,7 @@ BinWrapper.prototype.runCheck = function (cmd, cb) {
167168 }
168169
169170 cb ( ) ;
170- } . bind ( this ) ) ;
171+ } ) ;
171172} ;
172173
173174/**
@@ -178,7 +179,7 @@ BinWrapper.prototype.runCheck = function (cmd, cb) {
178179 */
179180
180181BinWrapper . prototype . findExisting = function ( cb ) {
181- fs . stat ( this . path ( ) , function ( err ) {
182+ fs . stat ( this . path ( ) , err => {
182183 if ( err && err . code === 'ENOENT' ) {
183184 this . download ( cb ) ;
184185 return ;
@@ -190,7 +191,7 @@ BinWrapper.prototype.findExisting = function (cb) {
190191 }
191192
192193 cb ( ) ;
193- } . bind ( this ) ) ;
194+ } ) ;
194195} ;
195196
196197/**
@@ -201,21 +202,19 @@ BinWrapper.prototype.findExisting = function (cb) {
201202 */
202203
203204BinWrapper . prototype . download = function ( cb ) {
204- var files = osFilterObj ( ) ( this . src ( ) ) ;
205- var download = new Download ( ) ( {
205+ const files = osFilterObj ( ) ( this . src ( ) ) ;
206+ const download = new Download ( ) ( {
206207 extract : true ,
207208 mode : '755' ,
208209 strip : this . opts . strip
209210 } ) ;
210211
211- if ( ! files . length ) {
212+ if ( files . length === 0 ) {
212213 cb ( new Error ( 'No binary found matching your system. It\'s probably not supported.' ) ) ;
213214 return ;
214215 }
215216
216- files . forEach ( function ( file ) {
217- download . get ( file . url ) ;
218- } ) ;
217+ files . forEach ( file => download . get ( file . url ) ) ;
219218
220219 download
221220 . dest ( this . dest ( ) )
0 commit comments