Skip to content

Commit

Permalink
fix: check if cwd changed to bust mapper cache (#219)
Browse files Browse the repository at this point in the history
*Co-authored-by: JounQin <admin@1stg.me>
  • Loading branch information
lsmurray authored Mar 29, 2023
1 parent 2671757 commit 0bf6ffb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/rich-icons-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-import-resolver-typescript": patch
---

fix: check if cwd changed to bust mapper cache
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ let previousOptionsHash: string
let optionsHash: string
let cachedOptions: InternalResolverOptions | undefined

let prevCwd: string

let mappersCachedOptions: InternalResolverOptions
let mappers: Array<((specifier: string) => string[]) | null> | undefined

Expand Down Expand Up @@ -347,9 +349,14 @@ function getMappedPath(
}

function initMappers(options: InternalResolverOptions) {
if (mappers && mappersCachedOptions === options) {
if (
mappers &&
mappersCachedOptions === options &&
prevCwd === process.cwd()
) {
return
}
prevCwd = process.cwd()

const configPaths =
typeof options.project === 'string'
Expand Down

0 comments on commit 0bf6ffb

Please sign in to comment.