This repository was archived by the owner on Jan 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,9 @@ tar.pack('./my-directory').pipe(fs.createWriteStream('my-tarball.tar'))
25
25
fs .createReadStream (' my-other-tarball.tar' ).pipe (tar .extract (' ./my-other-directory' ))
26
26
```
27
27
28
- To ignore various files when packing or extracting add a ignore function to the options. ` ignore ` is also an alias for ` filter ` .
28
+ To ignore various files when packing or extracting add a ignore function to the options. ` ignore `
29
+ is also an alias for ` filter ` . Additionally you get ` header ` if you use ignore while extracting.
30
+ That way you could also filter by metadata.
29
31
30
32
``` js
31
33
var pack = tar .pack (' ./my-directory' , {
@@ -39,6 +41,13 @@ var extract = tar.extract('./my-other-directory', {
39
41
return path .extname (name) === ' .bin' // ignore .bin files inside the tarball when extracing
40
42
}
41
43
})
44
+
45
+ var extractFilesDirs = tar .extract (' ./my-other-other-directory' , {
46
+ ignore : function (_ , header ) {
47
+ // pass files & directories, ignore e.g. symlinks
48
+ return header .type !== ' file' && header .type !== ' directory'
49
+ }
50
+ })
42
51
```
43
52
44
53
You can also specify which entries to pack using the ` entries ` option
Original file line number Diff line number Diff line change @@ -221,7 +221,7 @@ exports.extract = function (cwd, opts) {
221
221
header . name = normalize ( header . name )
222
222
var name = path . join ( cwd , path . join ( '/' , header . name ) )
223
223
224
- if ( ignore ( name ) ) {
224
+ if ( ignore ( name , header ) ) {
225
225
stream . resume ( )
226
226
return next ( )
227
227
}
You can’t perform that action at this time.
0 commit comments