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(function(resolve, reject) {
var file;
try {
file = util.path.urlToLocalPath(path);
}
catch (err) {
reject(ono.uri(err, 'Malformed URI: %s', path));
}
util.debug('Opening file: %s', file);
try {
fs.readFile(file, function(err, data) {
if (err) {
reject(ono(err, 'Error opening file "%s"', file));
}
else {
resolve(data);
}
});
}
catch (err) {
reject(ono(err, 'Error opening file "%s"', file));
return new Promise(function(resolve, reject) {
var file;
try {
file = util.path.urlToLocalPath($ref.path);
}
catch (err) {
reject(ono.uri(err, 'Malformed URI: %s', $ref.path));
}
util.debug('Opening file: %s', file);
try {
fs.readFile(file, function(err, data) {
if (err) {
reject(ono(err, 'Error opening file "%s"', $ref.path));
}
else {
resolve(data);
}
});
}
catch (err) {
reject(ono(err, 'Error opening file "%s"', file));