GithubHelp home page GithubHelp logo

Comments (11)

ctalkington avatar ctalkington commented on September 28, 2024 18

you can now use the following in v0.8.0:

archive.append(null, { name: 'directory/' });

from node-archiver.

shen-lin avatar shen-lin commented on September 28, 2024 3

you can now use the following in v0.8.0:

archive.append(null, { name: 'directory/' });

how to fill content into 'directory/ ?

@guanguanqingchao

The 2nd parameter of directory() and the name attribute in the 2nd param of append() can take file path as inputs.

        archive.directory('.../yourfolder', 'directory/yourfoler');
        archive.append(fs.createReadStream('.../yourfile'), { name: 'directory/yourfile' });

from node-archiver.

ctalkington avatar ctalkington commented on September 28, 2024 1

you would need to create an empty file with the path. something like..

archive.append('', { name: 'my/new/dir/.keep' });

from node-archiver.

newmanw avatar newmanw commented on September 28, 2024

Thanks! Also is there a way to point at a directory that exists on the file system and have it add that directory full of files to the archive?

Basically this is the only module that I have found that supports streaming dynamically created content as a zip file. However I do also have a few 'static' directories (stuff that exists on the server) that I would like to include in the zip.

from node-archiver.

ctalkington avatar ctalkington commented on September 28, 2024

not at this point in time, mainly because this module was created to assist a grunt task which already handles the file globbing and such. so it was never a key feature, however the audience has grown so it may be considered in a near future version.

from node-archiver.

darsain avatar darsain commented on September 28, 2024

I'd definitely need a way how to create empty folders in archives. Have been playing around with tar-stream module which does it by passing a type prop into header object:

var tar = require('tar-stream');
var pack = tar.pack();
pack.entry({ name: 'Dirname', type: 'directory' }, callback);

Would it be possible to support something like that?

Also, I've read in one of the issues that you are planning on adding a .directory() method, but that it will be used to bulk-add files from that particular directory. Is it necessary when you already have .bulk()? Couldn't you just modify it to add files from a directory when string is passed? Wouldn't it be more correct for .directory() to add an empty directory? You know like:

  • .file() - adds a file
  • .directory() - adds a directory

from node-archiver.

ctalkington avatar ctalkington commented on September 28, 2024

thanks for the feedback. directory was originally bulk but was renamed to make bit more sense. so i could actually make directory do what you mention.

v0.5 is going to contain quite a bit of change. tar archive building will be a wrapper around tar-stream to combine efforts as soon as I get a few PRs committed over there. ill likely split the core zip logic into its own published module soon too. my end goal is have to v0.5 out by the end of Jan.

from node-archiver.

ltomes avatar ltomes commented on September 28, 2024

archive.append(null, { name: 'directory/' });

Does this still work in the latest versions of node-archiver? I see directory was refactored in 2.1.0.

from node-archiver.

mhemrg avatar mhemrg commented on September 28, 2024

@ltomes Yes. It works with 3.0.0.

from node-archiver.

guanguanqingchao avatar guanguanqingchao commented on September 28, 2024

you can now use the following in v0.8.0:

archive.append(null, { name: 'directory/' });

how to fill content into 'directory/ ?

from node-archiver.

tsulatsitamim avatar tsulatsitamim commented on September 28, 2024

in version 7.0.1, use null create empty file inside the folder

from node-archiver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.