BrowserFS
BrowserFS copied to clipboard
mkdir under multiple hierarchy isn't working
fs.mkdir('/home', 1, function () {
console.log('directory created');
});
fs.mkdir('/src', 1, function () {
console.log('src created');
});
fs.mkdir('./components', 1, function () {
console.log('src created');
});
fs.mkdir('/components/test', function () { // this isn't creating the `test` directory
console.log('src created');
});
Here is the code sandbox
https://stackblitz.com/edit/react-l4u5ao?file=src%2FApp.js
I guess the components isn't yet created, you must either
nest the callbacks
use fs.mkdirSync but use a backend that supports sync
@arunkumar413 @neimanpinchas
The optional options argument can be an integer specifying mode (permission and sticky bits), or an object with a mode property and a recursive property indicating whether parent directories should be created. Calling fs.mkdir() when path is a directory that exists results in an error only when recursive is false.
When using fs.mkdir for nested directories you should set recursive to true in the options.