@@ -15,10 +15,8 @@ var fs = require('graceful-fs')
1515  ,  rm  =  require ( 'rimraf' ) 
1616  ,  path  =  require ( 'path' ) 
1717  ,  crypto  =  require ( 'crypto' ) 
18-   ,  zlib  =  require ( 'zlib' ) 
1918  ,  log  =  require ( 'npmlog' ) 
2019  ,  semver  =  require ( 'semver' ) 
21-   ,  fstream  =  require ( 'fstream' ) 
2220  ,  request  =  require ( 'request' ) 
2321  ,  minimatch  =  require ( 'minimatch' ) 
2422  ,  mkdir  =  require ( 'mkdirp' ) 
@@ -144,41 +142,33 @@ function install (gyp, argv, callback) {
144142      var  tarPath  =  gyp . opts . tarball 
145143      var  badDownload  =  false 
146144        ,  extractCount  =  0 
147-         ,  gunzip  =  zlib . createGunzip ( ) 
148-         ,  extracter  =  tar . Extract ( {  path : devDir ,  strip : 1 ,  filter : isValid  } ) 
149145
150146      var  contentShasums  =  { } 
151147      var  expectShasums  =  { } 
152148
153149      // checks if a file to be extracted from the tarball is valid. 
154150      // only .h header files and the gyp files get extracted 
155-       function  isValid  ( )  { 
156-         var  name  =  this . path . substring ( devDir . length  +  1 ) 
157-         var  isValid  =  valid ( name ) 
158-         if  ( name  ===  ''  &&  this . type  ===  'Directory' )  { 
159-           // the first directory entry is ok 
160-           return  true 
161-         } 
151+       function  isValid  ( path ,  entry )  { 
152+         var  isValid  =  valid ( path ) 
162153        if  ( isValid )  { 
163-           log . verbose ( 'extracted file from tarball' ,  name ) 
154+           log . verbose ( 'extracted file from tarball' ,  path ) 
164155          extractCount ++ 
165156        }  else  { 
166157          // invalid 
167-           log . silly ( 'ignoring from tarball' ,  name ) 
158+           log . silly ( 'ignoring from tarball' ,  path ) 
168159        } 
169160        return  isValid 
170161      } 
171162
172-       gunzip . on ( 'error' ,  cb ) 
173-       extracter . on ( 'error' ,  cb ) 
174-       extracter . on ( 'end' ,  afterTarball ) 
175- 
176-       // download the tarball, gunzip and extract! 
163+       // download the tarball and extract! 
177164
178165      if  ( tarPath )  { 
179-         var  input  =  fs . createReadStream ( tarPath ) 
180-         input . pipe ( gunzip ) . pipe ( extracter ) 
181-         return 
166+         return  tar . extract ( { 
167+           file : tarPath , 
168+           strip : 1 , 
169+           filter : isValid , 
170+           cwd : devDir 
171+         } ) . then ( afterTarball ,  cb ) 
182172      } 
183173
184174      try  { 
@@ -218,7 +208,11 @@ function install (gyp, argv, callback) {
218208        } ) 
219209
220210        // start unzipping and untaring 
221-         req . pipe ( gunzip ) . pipe ( extracter ) 
211+         res . pipe ( tar . extract ( { 
212+           strip : 1 , 
213+           cwd : devDir , 
214+           filter : isValid 
215+         } ) . on ( 'close' ,  afterTarball ) . on ( 'error' ,  cb ) ) 
222216      } ) 
223217
224218      // invoked after the tarball has finished being extracted 
0 commit comments