File tree Expand file tree Collapse file tree 6 files changed +24
-11
lines changed
packages/tailwindcss-patch/src Expand file tree Collapse file tree 6 files changed +24
-11
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " tailwindcss-patch " : patch
3
+ ---
4
+
5
+ feat: add ` patchOptions#cwd ` option
Original file line number Diff line number Diff line change @@ -43,10 +43,11 @@ export interface ExtractValidCandidatesOption {
43
43
sources ?: SourceEntry [ ]
44
44
base ?: string
45
45
css ?: string
46
+ cwd ?: string
46
47
}
47
48
48
49
export async function extractValidCandidates ( options ?: ExtractValidCandidatesOption ) {
49
- const cwd = process . cwd ( )
50
+ const defaultCwd = options ?. cwd ?? process . cwd ( )
50
51
const { sources, base, css } = defuOverrideArray <
51
52
Required < ExtractValidCandidatesOption > ,
52
53
Partial < ExtractValidCandidatesOption > [ ]
@@ -55,10 +56,10 @@ export async function extractValidCandidates(options?: ExtractValidCandidatesOpt
55
56
options ,
56
57
{
57
58
css : '@import "tailwindcss";' ,
58
- base : cwd ,
59
+ base : defaultCwd ,
59
60
sources : [
60
61
{
61
- base : cwd ,
62
+ base : defaultCwd ,
62
63
pattern : '**/*' ,
63
64
negated : false ,
64
65
} ,
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ export class TailwindcssPatcher {
108
108
109
109
async getClassCacheSet ( ) : Promise < Set < string > > {
110
110
const classSet = new Set < string > ( )
111
- const { tailwindcss } = this . patchOptions
111
+ const { tailwindcss, cwd } = this . patchOptions
112
112
if ( this . majorVersion === 4 ) {
113
113
const { v4 } = tailwindcss ?? { }
114
114
if ( Array . isArray ( v4 ?. cssEntries ) ) {
@@ -127,6 +127,7 @@ export class TailwindcssPatcher {
127
127
) . filter ( x => x ) as string [ ]
128
128
for ( const css of results ) {
129
129
const candidates = await extractValidCandidates ( {
130
+ cwd,
130
131
base : v4 ?. base ,
131
132
css,
132
133
sources : v4 ?. sources ?. map ( ( x ) => {
@@ -144,6 +145,7 @@ export class TailwindcssPatcher {
144
145
}
145
146
else {
146
147
const candidates = await extractValidCandidates ( {
148
+ cwd,
147
149
base : v4 ?. base ,
148
150
css : v4 ?. css ,
149
151
sources : v4 ?. sources ?. map ( ( x ) => {
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ export interface PatchOptions extends PatchUserConfig {
29
29
extendLengthUnits ?: boolean | ILengthUnitsPatchOptions
30
30
}
31
31
filter ?: ( className : string ) => boolean
32
+ cwd ?: string
32
33
}
33
34
34
35
export interface InternalPatchOptions extends PatchOptions {
Original file line number Diff line number Diff line change
1
+ import { defineConfig } from 'vitest/config'
2
+
3
+ export default defineConfig (
4
+ {
5
+ test : {
6
+ projects : [
7
+ 'packages/*' ,
8
+ ] ,
9
+ } ,
10
+ } ,
11
+ )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments