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

Don't create basename directory if copying directory into existing one #741

Closed
BetaHuhn opened this issue Mar 18, 2021 · 3 comments · Fixed by #788
Closed

Don't create basename directory if copying directory into existing one #741

BetaHuhn opened this issue Mar 18, 2021 · 3 comments · Fixed by #788
Assignees
Labels
enhancement New feature or request io

Comments

@BetaHuhn
Copy link

BetaHuhn commented Mar 18, 2021

Current implementation/problem

I want to copy the contents of a directory into another existing directory. Right now, because of these lines:

// If dest is an existing directory, should copy inside.
const newDest: string =
destStat && destStat.isDirectory()
? path.join(dest, path.basename(source))
: dest

The files/folders in the source directory get copied into another folder (the basename of the source path) inside the target directory.

For example, I want to copy the directory .github/ISSUE_TEMPLATE/ to issues/. With the current version of @actions/io the files will end up in issues/ISSUE_TEMPLATE instead of issues/ if issues/ already exists.

Describe the enhancement

Add an option to disable this behavior and copy all files from one directory into the other without creating the basename folder.

Code Snippet

const newDest: string =
    destStat && destStat.isDirectory() && copyInside // Add this new option
      ? path.join(dest, path.basename(source))
      : dest

Additional information

If there's another way of achieving this, please let me know. If not, I would be willing to create a PR for this.

@KELLZ77

This comment has been minimized.

@wsiim

This comment has been minimized.

@BetaHuhn
Copy link
Author

BetaHuhn commented May 5, 2021

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request io
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants