find-in-files
find-in-files copied to clipboard
findSync is not synchronous
As far as I can see findSync depends on the find library which implements traverseSync which uses fs.readdirSync
.
am I missing something?
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' }
.
I'm having the same issue as well. { state: 'pending' }