Open gmhenderson opened 7 years ago
Hmm, yeah that's not right. I'll look into it. thanks
Same problem here. I'm able to get it working by setting a timeout between copying and writing to the copied folders for now. Probably not the best workaround though.
function copyFilesAsync(path, destination) {
return new Promise((resolve, reject) => {
copy(path, destination, resolve);
})
}
function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
await copyFilesAsync('src/**/*', 'temp/src');
await timeout(100); // Throws error without awaited timeout
fs.writeFile("./temp/myfile.json", JSON.stringify(content, null, 4), function () {
resolve();
});
The callback isn't behaving as I expect when using glob file patterns.
This works as you might expect:
So, naturally, if I want to perform some action on
index.php
after its copied, I do something like:Now consider:
But then this doesn't work:
Output:
Why can't
fs.statSync
find the file when using the*
?