I'm trying to check with a function, if a file exists or not. For that, i'm using:
function checkDirectoryOrFile(pathToCheck) {
// Resolve the path
var sanitizedPath = path.resolve(pathToCheck);
var statusTest = null;
filesystem.access(sanitizedPath, filesystem.R_OK | filesystem.W_OK, function (error) {
// Is null when everything is fine
if(!error) {
// Update the return status to true
statusTest = true;
}
statusTest = false;
});
console.log(statusTest);
// Returns the status
return statusTest;
}
My problem is, that "statusTest" stays on "null" instead true or false. Any suggestions? I've tried to save the status in a superglobal, etc. but that won't help, to be honest..