Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: including multiple unrelated directories without leading directory elements in a single archive #415

Closed
aral opened this issue May 6, 2024 · 1 comment

Comments

@aral
Copy link

aral commented May 6, 2024

Not sure if this is the best way to do this but given it took me a moment to figure it out (as it does not seem to be a natively-supported use case), I thought I’d document it.

Please feel free to add to the documentation/examples or to close this and folks will still be able to find it if they search for it.

TL; DR: use symlinks.

How to include multiple directories from different places in the file system hierarchy in an archive without including the whole directory structure for any of them.

https://codeberg.org/aral/gists/src/branch/main/how-to-include-multiple-directories-from-different-places-in-the-file-system-hierarchy-in-an-archive-without-including-the-whole-directory-structure-for-any-of-them.md

@isaacs
Copy link
Owner

isaacs commented Jun 19, 2024

You could also append them to an archive.

Eg, to add /some/path/asdf and /other/path/foo to the same archive, do this:

const file = '/path/to/file.tar'
await tar.u({ file, cwd: '/some/path' }, ['asdf'])
await tar.u({ file, cwd: '/other/path' }, ['foo'])

Note the similarity:

#!/usr/bin/env bash
file='/path/to/file.tar'
tar u -f $file -C /some/path asdf
tar u -f $file -C /other/path foo

@isaacs isaacs closed this as completed Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants