@@ -76,7 +76,7 @@ exports.pack = function (cwd, opts) {
7676 fmode |= parseInt ( 222 , 8 )
7777 }
7878
79- var onlink = function ( filename , header ) {
79+ var onsymlink = function ( filename , header ) {
8080 xfs . readlink ( path . join ( cwd , filename ) , function ( err , linkname ) {
8181 if ( err ) return pack . destroy ( err )
8282 header . linkname = normalize ( linkname )
@@ -111,7 +111,7 @@ exports.pack = function (cwd, opts) {
111111 header . size = 0
112112 header . type = 'symlink'
113113 header = map ( header ) || header
114- return onlink ( filename , header )
114+ return onsymlink ( filename , header )
115115 }
116116
117117 // TODO: add fifo etc...
@@ -237,13 +237,20 @@ exports.extract = function (cwd, opts) {
237237 } )
238238 }
239239
240- var onlink = function ( ) {
240+ var onsymlink = function ( ) {
241241 if ( win32 ) return next ( ) // skip symlinks on win for now before it can be tested
242242 xfs . unlink ( name , function ( ) {
243243 xfs . symlink ( header . linkname , name , stat )
244244 } )
245245 }
246246
247+ var onlink = function ( ) {
248+ if ( win32 ) return next ( ) // skip links on win for now before it can be tested
249+ xfs . unlink ( name , function ( ) {
250+ xfs . link ( path . resolve ( cwd , header . linkname ) , name , stat )
251+ } )
252+ }
253+
247254 var onfile = function ( ) {
248255 var ws = xfs . createWriteStream ( name )
249256 var rs = mapStream ( stream , header )
@@ -265,15 +272,17 @@ exports.extract = function (cwd, opts) {
265272
266273 mkdirp ( path . dirname ( name ) , { fs : xfs } , function ( err ) {
267274 if ( err ) return next ( err )
268- if ( header . type === 'symlink' ) return onlink ( )
269275
270- if ( header . type !== 'file' ) {
271- if ( strict ) return next ( new Error ( 'unsupported type for ' + name + ' (' + header . type + ')' ) )
272- stream . resume ( )
273- return next ( )
276+ switch ( header . type ) {
277+ case 'file' : return onfile ( )
278+ case 'link' : return onlink ( )
279+ case 'symlink' : return onsymlink ( )
274280 }
275281
276- onfile ( )
282+ if ( strict ) return next ( new Error ( 'unsupported type for ' + name + ' (' + header . type + ')' ) )
283+
284+ stream . resume ( )
285+ next ( )
277286 } )
278287 } )
279288
0 commit comments