question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: Provide created path for fs.ensure*()

See original GitHub issue

It 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:closed
  • Created 7 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
loilocommented, Feb 17, 2017

Attached the PR. However I have to say one should be careful about merging it in. Now that the feature is documented, ensureFile, ensureLink and ensureSymlink 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.

1reaction
jprichardsoncommented, Feb 17, 2017

@Loilo - yep, please do!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found