@@ -76,7 +76,7 @@ exports.pack = function (cwd, opts) {
76
76
fmode |= parseInt ( 222 , 8 )
77
77
}
78
78
79
- var onlink = function ( filename , header ) {
79
+ var onsymlink = function ( filename , header ) {
80
80
xfs . readlink ( path . join ( cwd , filename ) , function ( err , linkname ) {
81
81
if ( err ) return pack . destroy ( err )
82
82
header . linkname = normalize ( linkname )
@@ -111,7 +111,7 @@ exports.pack = function (cwd, opts) {
111
111
header . size = 0
112
112
header . type = 'symlink'
113
113
header = map ( header ) || header
114
- return onlink ( filename , header )
114
+ return onsymlink ( filename , header )
115
115
}
116
116
117
117
// TODO: add fifo etc...
@@ -237,13 +237,20 @@ exports.extract = function (cwd, opts) {
237
237
} )
238
238
}
239
239
240
- var onlink = function ( ) {
240
+ var onsymlink = function ( ) {
241
241
if ( win32 ) return next ( ) // skip symlinks on win for now before it can be tested
242
242
xfs . unlink ( name , function ( ) {
243
243
xfs . symlink ( header . linkname , name , stat )
244
244
} )
245
245
}
246
246
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
+
247
254
var onfile = function ( ) {
248
255
var ws = xfs . createWriteStream ( name )
249
256
var rs = mapStream ( stream , header )
@@ -265,15 +272,17 @@ exports.extract = function (cwd, opts) {
265
272
266
273
mkdirp ( path . dirname ( name ) , { fs : xfs } , function ( err ) {
267
274
if ( err ) return next ( err )
268
- if ( header . type === 'symlink' ) return onlink ( )
269
275
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 ( )
274
280
}
275
281
276
- onfile ( )
282
+ if ( strict ) return next ( new Error ( 'unsupported type for ' + name + ' (' + header . type + ')' ) )
283
+
284
+ stream . resume ( )
285
+ next ( )
277
286
} )
278
287
} )
279
288
0 commit comments