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

Loading…
Cancel
Save