Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise(((resolve, reject) => {
let path;
try {
path = url.toFileSystemPath(file.url);
}
catch (err) {
reject(ono.uri(err, `Malformed URI: ${file.url}`));
}
// console.log('Opening file: %s', path);
try {
fs.readFile(path, (err, data) => {
if (err) {
reject(ono(err, `Error opening file "${path}"`));
}
else {
resolve(data);
}
});
}
catch (err) {
reject(ono(err, `Error opening file "${path}"`));