node-archiver icon indicating copy to clipboard operation
node-archiver copied to clipboard

Compress directory to zip wit this directory inside using glob and ignore functionality

Open skrasilnikoff opened this issue 3 years ago • 1 comments

Hello.

I want to add my directory to a zip archive and exclude some files and folders. It works ok if I do it like this:

archive
    .glob('**/*', {
      cwd: currentDir,
      ignore: ['.git*'],
    }, {});

But it put all files and folders from my selected directory to the zip. I want to put the selected Directory to the zip, not only files and folders from this Directory.

For example: zip should contain:

zip: 
|--- myDirectory
        |--- some file
        |--- some folder

But what I've got:

zip:
|--- some file
|--- some folder

I know that if I will use the following code, I will reach what I want about the Directory, but in this case I can't to exclude files and folders:

archive.directory(currentDir, 'myDirectory');

Could you help me with this issue?

Thanks

skrasilnikoff avatar Jan 30 '22 14:01 skrasilnikoff

Your means is the zip file should be contains currentDir?, Try use prefix entry data option?

aliuq avatar Apr 26 '22 14:04 aliuq

@aliuq

Your means is the zip file should be contains currentDir?, Try use prefix entry data option?

Thanks, that's what I needed!

skrasilnikoff avatar Sep 20 '22 18:09 skrasilnikoff