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

Move / rename files on extract #423

Open
hudlow opened this issue Oct 3, 2024 · 1 comment
Open

Move / rename files on extract #423

hudlow opened this issue Oct 3, 2024 · 1 comment

Comments

@hudlow
Copy link

hudlow commented Oct 3, 2024

It appears that onWriteEntry lets you move or rename a file when it's going into an archive, but can you do the same with transform or onReadEntry for files coming out of an archive? strip seems like a special case of this, but I'm trying to work out if I can transform and rename files without first writing them to disk and worrying about races.

@pdutourgeerling
Copy link

This is already possible :). For example, the following code extracts an archive while ignoring the folder structure

fs.createReadStream(archivePath)
    .pipe(decompressor)
    .pipe(tar.extract({
        onReadEntry: entry => {
            entry.path = path.basename(entry.path)
        }
    }))

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