find-in-files icon indicating copy to clipboard operation
find-in-files copied to clipboard

findSync is not synchronous

Open isaachinman opened this issue 8 years ago • 3 comments

isaachinman avatar Mar 01 '17 10:03 isaachinman

As far as I can see findSync depends on the find library which implements traverseSync which uses fs.readdirSync.

am I missing something?

purefan avatar Apr 04 '17 10:04 purefan

I too found that the findSync returned before actually completing, allowing the rest of my script to execute.

function doThething(){
  const files = [
    {dir: '.', name: '^config.xml', regex: /version="(.*?[^\\])"/},
  ];

  files.forEach((file, i) => {
    let test = findInFiles.findSync(file.regex, file.dir, file.name)
    .then(res => {
      console.log('result: ', res)
    })

    console.log('done', test);
  })
}

The console.log('done', test); fires long before the promise resolves. At this log, done returns { state: 'pending' }.

emcniece avatar Oct 11 '17 01:10 emcniece

I'm having the same issue as well. { state: 'pending' }

j avatar Feb 28 '18 19:02 j