Skip to content

Commit 0bf6ffb

Browse files
fix: check if cwd changed to bust mapper cache (#219)
*Co-authored-by: JounQin <admin@1stg.me>
1 parent 2671757 commit 0bf6ffb

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.changeset/rich-icons-hope.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-import-resolver-typescript": patch
3+
---
4+
5+
fix: check if cwd changed to bust mapper cache

src/index.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ let previousOptionsHash: string
119119
let optionsHash: string
120120
let cachedOptions: InternalResolverOptions | undefined
121121

122+
let prevCwd: string
123+
122124
let mappersCachedOptions: InternalResolverOptions
123125
let mappers: Array<((specifier: string) => string[]) | null> | undefined
124126

@@ -347,9 +349,14 @@ function getMappedPath(
347349
}
348350

349351
function initMappers(options: InternalResolverOptions) {
350-
if (mappers && mappersCachedOptions === options) {
352+
if (
353+
mappers &&
354+
mappersCachedOptions === options &&
355+
prevCwd === process.cwd()
356+
) {
351357
return
352358
}
359+
prevCwd = process.cwd()
353360

354361
const configPaths =
355362
typeof options.project === 'string'

0 commit comments

Comments
 (0)