Skip to content

Commit 4f54f95

Browse files
committed
ci: debug windows issue on CI
1 parent d08485b commit 4f54f95

File tree

5 files changed

+27
-5
lines changed

5 files changed

+27
-5
lines changed

.changeset/friendly-weeks-act.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"eslint-import-resolver-typescript": major
33
---
44

5-
feat!: rewrite, speed up by using `rspack-resolver` which supports `references` natively under the hood
5+
feat!: rewrite, speed up by using [`rspack-resolver`](https://github.com/unrs/rspack-resolver) which supports `references` natively under the hood
66

77
BREAKING CHANGES:
88

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,5 @@ jobs:
4747
- name: Lint and Test
4848
if: ${{ matrix.node != 16}}
4949
run: yarn run-s lint test
50+
env:
51+
DEBUG: eslint-import-resolver-typescript

src/helpers.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,8 @@ export const sortProjectsByAffinity = (projects: string[], file: string) => {
6666
.sort((a, b) => a.affinity - b.affinity)
6767
.map(item => item.project)
6868
}
69+
70+
export const toGlobPath = (pathname: string) => pathname.replaceAll('\\', '/')
71+
72+
export const toNativePath = (pathname: string) =>
73+
'/' === path.sep ? pathname : pathname.replaceAll('/', '\\')

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ export const resolve = (
8989

9090
if (!resolver) {
9191
const optionsHash = stableHash(options)
92-
options = normalizeOptions(options)
92+
const cwd = process.cwd()
93+
options = normalizeOptions(options, cwd)
9394
// take `cwd` into account -- #217
94-
const cacheKey = `${optionsHash}:${process.cwd()}`
95+
const cacheKey = `${optionsHash}:${cwd}`
9596
let cached = resolverCache.get(cacheKey)
9697
if (!cached && !options.project) {
9798
resolverCache.set(cacheKey, (cached = new ResolverFactory(options)))

src/normalize-options.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import path from 'node:path'
2+
13
import type { TsconfigOptions } from 'rspack-resolver'
24
import { globSync, isDynamicPattern } from 'tinyglobby'
35

@@ -10,7 +12,7 @@ import {
1012
defaultExtensions,
1113
defaultMainFields,
1214
} from './constants.js'
13-
import { tryFile } from './helpers.js'
15+
import { toNativePath, tryFile } from './helpers.js'
1416
import { log } from './logger.js'
1517
import type { TypeScriptResolverOptions } from './types.js'
1618

@@ -22,10 +24,12 @@ let warned: boolean | undefined
2224

2325
export function normalizeOptions(
2426
options?: TypeScriptResolverOptions | null,
27+
cwd?: string,
2528
): TypeScriptResolverOptions
2629
// eslint-disable-next-line sonarjs/cognitive-complexity
2730
export function normalizeOptions(
2831
options?: TypeScriptResolverOptions | null,
32+
cwd = process.cwd(),
2933
): TypeScriptResolverOptions {
3034
let { project, tsconfig, noWarnOnMultipleProjects } = (options ||= {})
3135

@@ -38,15 +42,25 @@ export function normalizeOptions(
3842
ensured = true
3943
} else if (project) {
4044
project = Array.isArray(project) ? project : [project]
45+
log('original projects:', ...project)
4146
if (project.some(p => isDynamicPattern(p))) {
47+
project = project.map(p =>
48+
path.isAbsolute(p) ? path.relative(cwd, p) : p,
49+
)
50+
log('relative path projects:', ...project)
4251
project = globSync(project, {
4352
absolute: true,
53+
cwd,
4454
dot: true,
55+
expandDirectories: false,
4556
onlyFiles: false,
4657
ignore: DEFAULT_IGNORE,
4758
})
4859
}
49-
project = project.flatMap(p => tryFile(DEFAULT_TRY_PATHS, false, p) || [])
60+
log('resolving projects:', ...project)
61+
project = project.flatMap(
62+
p => tryFile(DEFAULT_TRY_PATHS, false, toNativePath(p)) || [],
63+
)
5064
log('resolved projects:', ...project)
5165
if (project.length === 1) {
5266
configFile = project[0]

0 commit comments

Comments
 (0)