Skip to content

Commit 87e21e1

Browse files
committed
#19 | Sleep 100ms in atomicReplace
1 parent bc63502 commit 87e21e1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib/fileSystemHelpers.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ const ensureDirectory = async (path) => {
4040
* Building in a separate temp location releases all file handles
4141
* before the final swap.
4242
*/
43-
const atomicReplace = async (targetPath, buildFn) => {
43+
const atomicReplace = async (targetPath, buildFn, sleepTime = 100) => {
44+
const sleep = (duration) => new Promise(resolve => setTimeout(resolve, duration))
4445
const tempPath = await atomicFS.mkdtemp(join(tmpdir(), 'atomic-replace-'))
4546
try {
4647
await buildFn(tempPath)
4748
await atomicFS.rm(targetPath)
49+
await sleep(sleepTime)
4850
await atomicFS.cp(tempPath, targetPath)
4951
} catch (error) {
5052
await atomicFS.rm(tempPath)

0 commit comments

Comments
 (0)