From 0bf6ffb82bad35e96b22b7b7b91b94aa7ed875f8 Mon Sep 17 00:00:00 2001 From: lsmurray <123389894+lsmurray@users.noreply.github.com> Date: Wed, 29 Mar 2023 10:47:05 -0400 Subject: [PATCH] fix: check if cwd changed to bust mapper cache (#219) *Co-authored-by: JounQin --- .changeset/rich-icons-hope.md | 5 +++++ src/index.ts | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changeset/rich-icons-hope.md diff --git a/.changeset/rich-icons-hope.md b/.changeset/rich-icons-hope.md new file mode 100644 index 0000000..2668349 --- /dev/null +++ b/.changeset/rich-icons-hope.md @@ -0,0 +1,5 @@ +--- +"eslint-import-resolver-typescript": patch +--- + +fix: check if cwd changed to bust mapper cache diff --git a/src/index.ts b/src/index.ts index 54d17cc..438dd69 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 @@ -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'