Browse Source

switched fs.exists with fs.access in shepherd.js

all-modes
Petr Balashov 8 years ago
parent
commit
f64b77a66c
  1. 20
      routes/shepherd.js

20
routes/shepherd.js

@ -479,15 +479,17 @@ shepherd.readDebugLog = function(fileLocation, lastNLines) {
return new Promise(
function(resolve, reject) {
if (lastNLines) {
if (fs.existsSync(fileLocation)) {
console.log('reading ' + fileLocation);
readLastLines
.read(fileLocation, lastNLines)
.then((lines) => resolve(lines));
} else {
reject('file ' + fileLocation + ' doesn\'t exist!');
}
fs.access(fileLocation, fs.constants.R_OK, function(err) {
if (err) {
console.log('error reading ' + fileLocation);
reject('readDebugLog error: ' + err);
} else {
console.log('reading ' + fileLocation);
readLastLines
.read(fileLocation, lastNLines)
.then((lines) => resolve(lines));
}
});
} else {
reject('readDebugLog error: lastNLines param is not provided!');
}

Loading…
Cancel
Save