Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

93
Views
Push fs / chokidar data to array

I was using chokidar for the first time and I was trying to get all the file names in a directory and push them to an array. Chokidar successfully gets the file names but when I push them to array the names are not being registered. Or maybe they are being registered then being overwritten by an empty path when chokidar checks for updates. Either way, how can I get all the file names in an array. Any help is appreciated. Thanks in advance.

const chokidar = require('chokidar');

var currentData = []
chokidar.watch('./dirPATH').on('all', (event, path) => {
  //what I tried
  if (path != '' && path != ' ' && path != null && path != undefined) {
    currentData.push(path);
  }
  console.log(path) //prints path correctly
});


console.log(currentData) //prints empty array
//expected print array with items of file names aquired by chokidar

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!