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

Changing return value of Node.js recursive mkdir #21

Open
coreyfarrell opened this issue Feb 5, 2020 · 1 comment
Open

Changing return value of Node.js recursive mkdir #21

coreyfarrell opened this issue Feb 5, 2020 · 1 comment

Comments

@coreyfarrell
Copy link
Contributor

Per nodejs/node#31530 node.js will soon return the first directory created rather than returning the requested directory. So if ./tmp/ does not exist the following script:

console.log(fs.mkdirSync('tmp/subdir', {recursive: true}));
console.log(fs.mkdirSync('tmp/subdir', {recursive: true}));

This will print tmp then undefined instead of printing tmp/subdir (also the result is never path.resolve'd). Knowing the first directory created can be useful when you need to set permissions or ownership of the created directories.

The node.js change itself will be masked by make-dir which returns path.resolve(input) but I think it would be useful for make-dir to emulate this new functionality. Maybe need to wait until it's known what versions of node.js will get this new functionality so useNativeRecursiveOption can be updated to ensure native is only used if it provides the result?

@sindresorhus
Copy link
Owner

Makes sense to align with Node.js behavior.


Maybe need to wait until it's known what versions of node.js will get this new functionality so useNativeRecursiveOption can be updated to ensure native is only used if it provides the result?

Yes, I think it would be good to know that beforehand.

@sindresorhus sindresorhus changed the title Changing return value of node.js recursive mkdir Changing return value of Node.js recursive mkdir Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants