We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bc63502 commit 87e21e1Copy full SHA for 87e21e1
src/lib/fileSystemHelpers.js
@@ -40,11 +40,13 @@ const ensureDirectory = async (path) => {
40
* Building in a separate temp location releases all file handles
41
* before the final swap.
42
*/
43
-const atomicReplace = async (targetPath, buildFn) => {
+const atomicReplace = async (targetPath, buildFn, sleepTime = 100) => {
44
+ const sleep = (duration) => new Promise(resolve => setTimeout(resolve, duration))
45
const tempPath = await atomicFS.mkdtemp(join(tmpdir(), 'atomic-replace-'))
46
try {
47
await buildFn(tempPath)
48
await atomicFS.rm(targetPath)
49
+ await sleep(sleepTime)
50
await atomicFS.cp(tempPath, targetPath)
51
} catch (error) {
52
await atomicFS.rm(tempPath)
0 commit comments