1.10.20. fejezet, Zip tömörítés

Kapcsolódó hivatkozások

import AdmZip from "adm-zip";
import fs from "fs";
import path from "path";
 
const zip = new AdmZip();
const directoryPath = "PATH_TO_DIR";
fs.readdir(directoryPath, function (err, files) {
    if (err) {
        return console.log('Unable to scan directory: ' + err);
    }
    files.forEach(function (file) {
        const fileName = path.join(directoryPath, file);
        if (fs.lstatSync(fileName).isFile()) {
            console.log("added:", file);
            zip.addLocalFile(fileName);
        }
    });
    zip.writeZip("e:/temp/files.zip");
});