Monday 27 August 2018

Packing files with the 'targz' package and ignoring .txt files

So I am currently trying to pack all the contents of a folder, but now I want it to ignore all files with a certain extension. The code I have looks like this:targz.compress({ src: "./" + this.sourcePath + "/", dest: "./" + this.targetPath + "/" + "result.tar.gz", tar: { entries: this.fileArray, ignore: function(name) { return path.extname(name) === '.txt' } }, gz: { level: 6, memLevel: 6, } }, function(err){ if(err) { console.log(err); reject(err); } else { resolve(); } }); As I just started with node, I have no idea how I can write this ignore filter into the code in a way that it works: ignore: function(name) { return path.extname(name) === '.txt' } It is supposed to ignore all files with the extension '.txt'.If this is the wrong place to ask please tell me where else I can ask for help :)

Submitted August 27, 2018 at 12:57PM by Rado86

No comments:

Post a Comment