Tenderly / tenderly-cli

CLI tool for Smart Contract error tracking, monitoring and alerting.
https://tenderly.co
GNU General Public License v3.0
522 stars 137 forks source link

Adding `walkSymlink` function to support walking symlinks when zipping dirs. #136

Closed g4ndr4 closed 1 year ago

g4ndr4 commented 1 year ago

Context

Our Zip function in zip/zip.go:Zip relies on https://pkg.go.dev/path/filepath#WalkDir which doesn't follow symlinks. This causes issues with monorepos where local dependencies are symlinked in node_modules. Since the symlink cannot be resolved, the build process fails during zip creation.

What is this PR solving

This PR is meant to enable our zip/zip.go:Zip function to follow symlinks, properly resolve them and add the files in the symlinked dirs to the output zip.

How is this PR solving it

It is adding a new method walkSymlink(writer *zip.Writer, files *[]string, path string, destBasePath string) error which firs evaluates symlinked dir passed as the path argument and then continues with the resolved dir in the same way as the filepath.WalkDir function behaved in our Zip function.