Node Electron synch text append

78
January 10, 2020, at 7:50 PM

I am trying to make an Electron app that will read given directory recursively and print file names to user. Luckily I found a function on GitHub which makes exactly what I want. (Link here).

When function finds files one by one, I want to show user which file has just found.

console.log running fine and I get what I want at exact time. But I don't want users to see developer tools. So I want to print this text somewhere else in DOM.

In this case I added div called show_files and wanted to add texts in this div via Jquery's append function but append function works after everything is done.

I know Node.js working asynchronously but I use everything synchronously in this example. What I am doing wrong or how can I solve this problem?

Code below.

var walkSync = function(dir, fileNameList) {
  var fs = fs || require('fs');
  var path = path || require('path');
  var files = fs.readdirSync(dir);
  fileNameList = fileNameList || [];
  files.forEach(function(file) {
    logs.prepend(file);
    if (fs.statSync(path.join(dir, file)).isDirectory()) {
      fileNameList = walkSync(path.join(dir, file), fileNameList);
    } else {
      fileNameList.push(file);
      // CHECK HERE -> This runs properly.
      console.log(file);
      // CHECK HERE -> This runs after everything is done.
      $('#show_files').append(file + "\n");
    }
  });
  return fileNameList;
};

Thanks.

READ ALSO
Data and salt arguments required error (authorization)

Data and salt arguments required error (authorization)

I'm a beginner in NodeJS and I've tried to make an authentication form using NodeJS + expressI want to make a validation for my password (when "confirmpassword" is different than "password" it should return nothing

205
Configuring express gateway to work with redis

Configuring express gateway to work with redis

I'm setting up an instance of the express gateway for routing requests to microservicesIt works as expected, but I get the following errors when I try to include redis in my system config

93
Heroku fetching api data : Error 414 URI too long

Heroku fetching api data : Error 414 URI too long

I have a nodejs server deployed on heorku (hosting provider) and i'm receiving a 414 URI Too Long error

77
Biometric push in Nodejs

Biometric push in Nodejs

In documentation of Biometric, initialization of information exchangeTelling

103