Feat/34 safe ouput dir overwrite#39
Merged
Merged
Conversation
7e9c637 to
e6b897e
Compare
e6b897e to
dc493e8
Compare
hofp37
reviewed
Jul 31, 2025
|
|
||
| if (toolbelt.isDirectoryNonEmpty(destination)) { | ||
| if (!parsedArgs.force) { | ||
| logger.info( |
Collaborator
There was a problem hiding this comment.
Optional: Single log could be used
| return path.normalize(str) as Path | ||
| } | ||
|
|
||
| public isDirectoryNonEmpty(dirpath: string): boolean { |
Collaborator
There was a problem hiding this comment.
Optional: Having isDirectoryEmpty instead would be more clearer - maybe just my POV
Member
There was a problem hiding this comment.
Refactored, I like the idea. 👍
| if (!rootPath.includes(dirpath)) { | ||
| if (fs.existsSync(dirpath) && option?.overwrite) { | ||
| fs.rmSync(dirpath, { recursive: true }) | ||
| if (fs.existsSync(dirpath)) { |
Collaborator
There was a problem hiding this comment.
Something like this would seem easier to read to me. What do you think?
if (fs.existsSync(dirpath) && option?.overwrite) {
fs.rmSync(dirpath, { recursive: true })
}
fs.mkdirSync(dirpath, { recursive: true })
dc493e8 to
b522871
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stop if destination directory exists. Add force overwrite destination directory flag.
Fixes #34