Skip to content

fix: allow non-normalized paths as input to mkdir#635

Merged
freitagbr merged 1 commit intomasterfrom
fix-non-normalized-path
Jan 8, 2017
Merged

fix: allow non-normalized paths as input to mkdir#635
freitagbr merged 1 commit intomasterfrom
fix-non-normalized-path

Conversation

@nfischer
Copy link
Copy Markdown
Member

Adds tests to make sure that non-normalized paths (i.e. path/to/./dir) are
valid for a few commands, including mkdir() which previously failed when given
the -p flag.

Fixes #634

Adds tests to make sure that non-normalized paths (i.e. path/to/./dir) are
valid for a few commands, including mkdir() which previously failed when given
the -p flag.

Fixes #634
@nfischer nfischer added the fix Bug/defect, or a fix for such a problem label Dec 21, 2016
@nfischer nfischer added this to the v0.7.x milestone Dec 21, 2016
@nfischer nfischer requested a review from freitagbr December 21, 2016 04:53
try {
if (options.fullpath) {
mkdirSyncRecursive(dir);
mkdirSyncRecursive(path.resolve(dir));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like fs.mkdirSync normalizes the path passed to it anyway. Is that why path.resolve is not needed below?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct.

It's needed here because, for each recursive call, we process another piece of the path. This can lead us to processing something that isn't valid for mkdir, like . or ... It can also lead us to processing the same directory twice (ex. foo/../foo/) which also isn't valid.

@nfischer
Copy link
Copy Markdown
Member Author

nfischer commented Jan 8, 2017

@freitagbr LGTY?

@freitagbr
Copy link
Copy Markdown
Contributor

Yes, LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug/defect, or a fix for such a problem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants