cthackers / adm-zip

A Javascript implementation of zip for nodejs. Allows user to create or extract zip files both in memory or to/from disk
MIT License
2.05k stars 375 forks source link

addFile: cannot create a directory #181

Open warpdesign opened 7 years ago

warpdesign commented 7 years ago

From the API documentation:

If you want to create a directory the entryName must end in / and a null buffer should be provided.

When typing this zip.addFile('myDir/', null), I'm getting this error:

node_modules\adm-zip\adm-zip.js:280 if (entry.isDirectory && content.length) { ^ TypeError: Cannot read property 'length' of null

ivome commented 7 years ago

This here works for me:

const zip = new AdmZip();
zip.addFile('dirname/', new Buffer(''));
seanpmaxwell commented 3 years ago

Almost 4 years later, this hasn't been fixed...