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

archiver.directory doesn't follow symbolic link #402

Open
soichih opened this issue Dec 1, 2019 · 2 comments
Open

archiver.directory doesn't follow symbolic link #402

soichih opened this issue Dec 1, 2019 · 2 comments

Comments

@soichih
Copy link

soichih commented Dec 1, 2019

I am trying to add a directory full of symbolic links to my archive by doing something ..

archive.directory("/some/dir_with_symlinks", "dir");

I have a lot of symbolic links inside /some/dir, and I want to deference(?) all those symbolic links so that I can store the actual files inside my archive. Is there a way to do it with node-archiver?

@soichih
Copy link
Author

soichih commented Dec 1, 2019

I decided to just walk the directory and append() each files as regular files.

async function walk(dir) {
    let files = await fs.promises.readdir(dir);
    files = await Promise.all(files.map(async file => {
        const filePath = path.join(dir, file);
        const stats = await fs.promises.stat(filePath);
        if (stats.isDirectory()) return walk(filePath);
        else if(stats.isFile()) return filePath;
    }));
    return files.reduce((all, folderContents) => all.concat(folderContents), []);
}

let entries = await walk(source_path);
entries.forEach(entry=>{
    let subpath = entry.substring(source_path.length);
    console.log(entry, file.dest+subpath);
    archive.append(fs.createReadStream(entry), {name: file.dest+subpath});
}); 

It's too bad that node-archiver doesn't provide this capability, but I hope this helps someone.

@ahtokca
Copy link

ahtokca commented Oct 14, 2021

Whould be nice to fix it for the archiverjs

archiver is used by amplify cli to zip node modules of lambdas. In case you have dependency to local folders then the local folders are shipped as simlinks. It breaks lambda deployments.

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