Feature request: Provide created path for fs.ensure*()
See original GitHub issueIt would in some cases be useful to get feedback at which point an fs.ensure*()
method did start to create a folder structure.
Two examples will probably clarify this best:
// Existing path: /my/example/path
// Example 1
fs.ensureDir('/my/example/path/with/some/additions', function (err, created) {
assert(created === '/my/example/path/with')
})
// Example 2
fs.ensureDir('/my/example', function (err, created) {
assert(created === null)
})
My concrete use case is that I have to run fs.ensureDir()
with root privileges and then set the owner back to the user who ran the command.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Feature request: provide deep (recursive) fs.writeFile() #37733
writeFileSync() ) with the { recursive: true } option that's available on fs.mkdir() and its friends. const path = require('path') const ...
Read more >How to create full path with node's fs.mkdirSync?
I'd like to be able to create the full path with as few lines of code as necessary. I read there is a...
Read more >File system | Node.js v19.3.0 Documentation
Convenience method to create a readline interface and stream over the file. See filehandle.createReadStream() for the options. import { open } from 'node:fs/ ......
Read more >fs-extra - npm
fs -extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.
Read more >Node.js — Check If a Path or File Exists - Future Studio
Future Studio provides on-demand learning & wants you to become a better ... Node.js comes with the fs core module allowing you to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Attached the PR. However I have to say one should be careful about merging it in. Now that the feature is documented,
ensureFile
,ensureLink
andensureSymlink
would implicitely be expected to behave similarly (which they don’t).Since they are all internally using
mkdir
though it would be maybe worth to think about adding that behaviour.@Loilo - yep, please do!