Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. resolveData: function(env, cb) {
  2. var dir = logsDirectory + "/" + env;
  3. var results = [];
  4. fs.readdir(dir, function(err, files) {
  5. if (err) {
  6. throw err;
  7. }
  8. var logFile = getNewestFile(files, dir)
  9. fs.createReadStream(dir + '/' + logFile, 'utf8')
  10. .pipe(split())
  11. .on('data', function(line) {
  12. var linesLength = 100;
  13. var lines = line.split('n');
  14. results.push({
  15. data: lines
  16. });
  17. console.log(line);
  18. });
  19. }, function(err) {
  20. if (err)
  21. throw err;
  22. cb(null, results);
  23. });
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement