Skip to content

Commit 0b2cf09

Browse files
committed
wip
1 parent 49e3bfb commit 0b2cf09

File tree

4 files changed

+65
-22
lines changed

4 files changed

+65
-22
lines changed

packages/tailwindcss-language-server/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"enhanced-resolve": "^5.16.1",
6767
"esbuild": "^0.24.0",
6868
"fast-glob": "3.2.4",
69+
"fdir": "^6.4.3",
6970
"find-up": "5.0.0",
7071
"jiti": "^2.3.3",
7172
"klona": "2.0.4",
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { fdir } from 'fdir'
2+
3+
interface SearchFilesOptions {
4+
/** The directory to search in */
5+
root: string
6+
7+
/** A list of patterns to include */
8+
include: string[]
9+
10+
/** A list of patterns to exclude */
11+
exclude: string[]
12+
13+
/**
14+
* Control whether or not an entry should be yielded or traversed
15+
*/
16+
filterEntry?(path: string, isDirectory: boolean): boolean
17+
}
18+
19+
export function searchFiles(opts: SearchFilesOptions) {
20+
return new fdir({
21+
// onlyFiles: true
22+
includeDirs: false,
23+
excludeFiles: false,
24+
25+
// absolute: true
26+
relativePaths: false,
27+
resolvePaths: true,
28+
includeBasePath: true,
29+
30+
// followSymbolicLinks: true
31+
resolveSymlinks: true,
32+
excludeSymlinks: false,
33+
34+
//
35+
suppressErrors: true,
36+
37+
// Normalize Windows paths to use forward slashes
38+
pathSeparator: '/',
39+
40+
filters: [(path, isDirectory) => opts.filterEntry?.(path, isDirectory) ?? true],
41+
42+
exclude: (name, path) => false,
43+
})
44+
.crawl(opts.root)
45+
.withPromise()
46+
}

packages/tailwindcss-language-server/src/project-locator.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import * as os from 'node:os'
21
import * as path from 'node:path'
32
import * as fs from 'node:fs/promises'
4-
import glob from 'fast-glob'
53
import picomatch from 'picomatch'
64
import type { Settings } from '@tailwindcss/language-service/src/util/state'
75
import { CONFIG_GLOB, CSS_GLOB } from './lib/constants'
@@ -17,6 +15,7 @@ import { normalizeDriveLetter, normalizePath, pathToFileURL } from './utils'
1715
import postcss from 'postcss'
1816
import * as oxide from './oxide'
1917
import { guessTailwindVersion, TailwindVersion } from './version-guesser'
18+
import { searchFiles } from './glob'
2019

2120
export interface ProjectConfig {
2221
/** The folder that contains the project */
@@ -276,8 +275,8 @@ export class ProjectLocator {
276275

277276
private async findConfigs(): Promise<ConfigEntry[]> {
278277
// Look for config files and CSS files
279-
let files = await this.glob({
280-
base: this.base,
278+
let files = await searchFiles({
279+
root: this.base,
281280
include: [`**/${CONFIG_GLOB}`, `**/${CSS_GLOB}`],
282281
exclude: this.settings.tailwindCSS.files.exclude,
283282
})
@@ -512,24 +511,6 @@ export class ProjectLocator {
512511
isDefaultVersion: true,
513512
}
514513
}
515-
516-
private async glob(options: {
517-
base: string
518-
include: string[]
519-
exclude: string[]
520-
}): Promise<string[]> {
521-
let files = await glob(options.include, {
522-
cwd: options.base,
523-
ignore: options.exclude,
524-
onlyFiles: true,
525-
absolute: true,
526-
suppressErrors: true,
527-
dot: true,
528-
concurrency: Math.max(os.cpus().length, 1),
529-
})
530-
531-
return files
532-
}
533514
}
534515

535516
function contentSelectorsFromConfig(

pnpm-lock.yaml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)