Skip to content

Commit c9f4e30

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

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

Diff for: .changeset/friendly-weeks-act.md

+1-1
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

Diff for: .github/workflows/ci.yml

+2
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

Diff for: src/helpers.ts

+5
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('/', '\\')

Diff for: src/index.ts

+3-2
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)))

Diff for: src/normalize-options.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
defaultExtensions,
1111
defaultMainFields,
1212
} from './constants.js'
13-
import { tryFile } from './helpers.js'
13+
import { toGlobPath, toNativePath, tryFile } from './helpers.js'
1414
import { log } from './logger.js'
1515
import type { TypeScriptResolverOptions } from './types.js'
1616

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

2323
export function normalizeOptions(
2424
options?: TypeScriptResolverOptions | null,
25+
cwd?: string,
2526
): TypeScriptResolverOptions
2627
// eslint-disable-next-line sonarjs/cognitive-complexity
2728
export function normalizeOptions(
2829
options?: TypeScriptResolverOptions | null,
30+
cwd = process.cwd(),
2931
): TypeScriptResolverOptions {
3032
let { project, tsconfig, noWarnOnMultipleProjects } = (options ||= {})
3133

@@ -37,16 +39,22 @@ export function normalizeOptions(
3739
configFile = tryFile(configFile)
3840
ensured = true
3941
} else if (project) {
40-
project = Array.isArray(project) ? project : [project]
42+
project = (Array.isArray(project) ? project : [project]).map(toGlobPath)
43+
log('original projects:', ...project)
4144
if (project.some(p => isDynamicPattern(p))) {
4245
project = globSync(project, {
4346
absolute: true,
47+
cwd,
4448
dot: true,
49+
expandDirectories: false,
4550
onlyFiles: false,
4651
ignore: DEFAULT_IGNORE,
4752
})
4853
}
49-
project = project.flatMap(p => tryFile(DEFAULT_TRY_PATHS, false, p) || [])
54+
log('resolving projects:', ...project)
55+
project = project.flatMap(
56+
p => tryFile(DEFAULT_TRY_PATHS, false, toNativePath(p)) || [],
57+
)
5058
log('resolved projects:', ...project)
5159
if (project.length === 1) {
5260
configFile = project[0]

0 commit comments

Comments
 (0)