I’m just starting to play with the FileSystem
module, so there may be more to come, but could you guys please make FileSystem.createDirectory()
resolve true
when its created or if its created, or make it reject if its already created. There’s no way of knowing, right now I have to do this:
FS.exists(FS.dataDirectory + '/user').then(function (userDirectoryExists) {
if(!userDirectoryExists) {
return FS.createDirectory(FS.dataDirectory + '/user').then(function (directoryCreated) {
return true;
}).catch(function (err) {
return false;
});
} else {
return true;
}
}).then(function (directory) {
if(userDirectoryExists) {
}
});
I’m writing way too many if statements for something Promises solve automatically
If the change is made I could write this:
FS.createDirectory(FS.dataDirectory + '/user').then(function (userDirectoryExists) {
console.log('Dir Exist:', userDirectoryExists); // true
});
If there’s a reason for that choice could someone please explain why perhaps I’m missing something