You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.
the problem I have is that the generated .tgz has the "bar" directory in the root and I'd like to have only the content of that directory (i.e. foo.txt, bar.bin, folder).
Is there a way i can do this?
thanks,
The text was updated successfully, but these errors were encountered:
A "better" solution is to use the filter option, and use it to modify the root of all the immediate entries of the the given directory. Hope this helps :
// Requires
var path = require('path');
var tar = require("tar");
var zlib = require("zlib");
var fstream = require("fstream");
function pipeTarGzDir(dirPath) {
var fullPath = path.resolve(dirPath);
return fstream.Reader({
path: fullPath,
type: "Directory",
filter: function () {
if(this.dirname == fullPath) {
this.root = null;
}
return !(this.basename.match(/^\.git/) || this.basename.match(/^node_modules/));
}
})
.pipe(tar.Pack())
.pipe(zlib.createGzip());
}
// Exports
exports.pipeTarGzDir = pipeTarGzDir;
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have directory like:
and I do something like
the problem I have is that the generated .tgz has the "bar" directory in the root and I'd like to have only the content of that directory (i.e. foo.txt, bar.bin, folder).
Is there a way i can do this?
thanks,
The text was updated successfully, but these errors were encountered: