Skip to content

Commit cf88236

Browse files
committed
fix: use @gar/promise-retry instead of promise-retry
1 parent 60f332c commit cf88236

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

workspaces/libnpmexec/lib/with-lock.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const fs = require('node:fs/promises')
22
const { rmdirSync } = require('node:fs')
3-
const promiseRetry = require('promise-retry')
3+
const { promiseRetry } = require('@gar/promise-retry')
44
const { onExit } = require('signal-exit')
55

66
// a lockfile implementation inspired by the unmaintained proper-lockfile library
@@ -67,12 +67,7 @@ async function withLock (lockPath, cb) {
6767
}
6868

6969
function acquireLock (lockPath) {
70-
return promiseRetry({
71-
minTimeout: 100,
72-
maxTimeout: 5_000,
73-
// if another process legitimately holds the lock, wait for it to release; if it dies abnormally and the lock becomes stale, we'll acquire it automatically
74-
forever: true,
75-
}, async (retry) => {
70+
return promiseRetry(async (retry) => {
7671
try {
7772
await fs.mkdir(lockPath)
7873
} catch (err) {
@@ -107,6 +102,11 @@ function acquireLock (lockPath) {
107102
} catch (err) {
108103
throw Object.assign(new Error('Lock compromised'), { code: 'ECOMPROMISED' })
109104
}
105+
}, {
106+
minTimeout: 100,
107+
maxTimeout: 5_000,
108+
// if another process legitimately holds the lock, wait for it to release; if it dies abnormally and the lock becomes stale, we'll acquire it automatically
109+
forever: true,
110110
})
111111
}
112112

0 commit comments

Comments
 (0)