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

Custom mkdirp (Issue #165) #169

Merged
merged 3 commits into from
Jun 28, 2016
Merged

Custom mkdirp (Issue #165) #169

merged 3 commits into from
Jun 28, 2016

Conversation

virtuakazib
Copy link

@virtuakazib virtuakazib commented May 9, 2016

Custom mkdir implementation that include the ability to update the
permissions mode on a directory that already exists.

This is an initial cut at this feature that works with passing unit tests on OS X. Haven't been able to verify Windows and Linux compatibility yet.

There are also probably coding convention and style preferences to fix.

Custom mkdir implementation that include the ability to update the
permissions mode on a directory that already exists.
New tests will skip on Windows.
Make sure directory is properly deleted before next test.
@virtuakazib virtuakazib changed the title Custom mkdirp Custom mkdirp (Issue #165) May 9, 2016
var cb = callback || function() {};
dirpath = path.resolve(dirpath);

fs.mkdir(dirpath, m, function(er) {
Copy link
Member

Choose a reason for hiding this comment

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

why does this attempt to use fs.mkdir before mkdirp (only if ENOENT)?

Copy link
Author

Choose a reason for hiding this comment

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

The initial fs.mkdir call ends the recursion on success. If a parent directory doesn't exist, it recursively calls 'mkdirp' up the path until fs.mkdir succeeds. Then calls mkdir back down the path.

Copy link
Member

Choose a reason for hiding this comment

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

It doesn't seem to call mkdir back down the path (cb is being called, ending the cycle). This probably shouldn't be using mkdirp at all because it has to chmod each path segment

Copy link
Author

Choose a reason for hiding this comment

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

The mkdir back down the path is on line 221. It's actually another mkdirp call.

One clarifying question on mode:
When mode is provided, all newly created directories will be created with that mode. And currently, if the final directory on the path already exists, then chmod will be called to change the mode.

Do you want ALL existing directories in the provided dirpath parameter to change permission?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I believe the desire is to have every directory updated.

Copy link
Member

Choose a reason for hiding this comment

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

Also, I was thinking it was still using the mkdirp module, totally forgot that the function was named mkdirp (ignore my comments about that).

Copy link
Author

Choose a reason for hiding this comment

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

Gotcha. I will try to add that mode detail in the next day or two.

@erikkemperman
Copy link
Member

erikkemperman commented May 12, 2016

@virtuakazib @phated I like this idea -- it removes the need to subvert the setuid/setgid/sticky tests on MacOSX, as currently done here. Unfortunately I discovered too late (after this PR was merged) what was actually up with that:

mkdirp (the module we were using, not the function here) restricts the mode bits to 777 (and excludes the bits set in umask) but the reason is likely that, on MacOSX, the resulting mode of creating a directory is unspecified if it includes "special" attributes. The manpages for the mkdir syscall says that in such cases we should follow up with a chmod which is effectively what this PR would do.

EDIT Hm, actually it is more complicated still... The current master branch fails npm test on my Mint machine, while it passed on travis' Debian. So the isDarwin check in the tests doesn't cover it. Anyway, once something like this PR were merged we could make all this go away :-)

@erikkemperman
Copy link
Member

@virtuakazib @phated Any news on this? No pressure, I was just looking forward to not having to hack this isDarwin in the tests to make them pass on my Mac.

By the way, I was curious, why are the new tests in this PR skipped entirely for Windows? Wouldn't it be better to test the creation of dirs and only skip testing their modes?

@phated
Copy link
Member

phated commented May 20, 2016

@erikkemperman thanks for following up but it looks like changes are still to be made based on my comments.

@phated
Copy link
Member

phated commented May 28, 2016

@virtuakazib will you have anytime soon to make the changes?

erikkemperman referenced this pull request in erikkemperman/vinyl-fs Jun 7, 2016
@phated phated merged commit 5eeaa57 into gulpjs:3.0 Jun 28, 2016
@phated
Copy link
Member

phated commented Jun 28, 2016

This needs a few basic tests for Windows (that just check the directories are created).

phated pushed a commit that referenced this pull request Jun 28, 2016
phated pushed a commit that referenced this pull request Nov 27, 2017
phated pushed a commit that referenced this pull request Nov 27, 2017
phated pushed a commit that referenced this pull request Nov 27, 2017
phated pushed a commit that referenced this pull request Nov 27, 2017
phated pushed a commit that referenced this pull request Nov 27, 2017
phated pushed a commit that referenced this pull request Nov 27, 2017
phated pushed a commit that referenced this pull request Nov 27, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 28, 2017
phated pushed a commit that referenced this pull request Nov 30, 2017
phated pushed a commit that referenced this pull request Nov 30, 2017
phated pushed a commit that referenced this pull request Nov 30, 2017
phated pushed a commit that referenced this pull request Nov 30, 2017
phated pushed a commit that referenced this pull request Nov 30, 2017
phated pushed a commit that referenced this pull request Dec 5, 2017
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

Successfully merging this pull request may close these issues.

4 participants