File tree Expand file tree Collapse file tree
packages/tailwindcss-patch/src Expand file tree Collapse file tree 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 {
4343 sources ?: SourceEntry [ ]
4444 base ?: string
4545 css ?: string
46+ cwd ?: string
4647}
4748
4849export async function extractValidCandidates ( options ?: ExtractValidCandidatesOption ) {
49- const cwd = process . cwd ( )
50+ const defaultCwd = options ?. cwd ?? process . cwd ( )
5051 const { sources, base, css } = defuOverrideArray <
5152 Required < ExtractValidCandidatesOption > ,
5253 Partial < ExtractValidCandidatesOption > [ ]
@@ -55,10 +56,10 @@ export async function extractValidCandidates(options?: ExtractValidCandidatesOpt
5556 options ,
5657 {
5758 css : '@import "tailwindcss";' ,
58- base : cwd ,
59+ base : defaultCwd ,
5960 sources : [
6061 {
61- base : cwd ,
62+ base : defaultCwd ,
6263 pattern : '**/*' ,
6364 negated : false ,
6465 } ,
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ export class TailwindcssPatcher {
108108
109109 async getClassCacheSet ( ) : Promise < Set < string > > {
110110 const classSet = new Set < string > ( )
111- const { tailwindcss } = this . patchOptions
111+ const { tailwindcss, cwd } = this . patchOptions
112112 if ( this . majorVersion === 4 ) {
113113 const { v4 } = tailwindcss ?? { }
114114 if ( Array . isArray ( v4 ?. cssEntries ) ) {
@@ -127,6 +127,7 @@ export class TailwindcssPatcher {
127127 ) . filter ( x => x ) as string [ ]
128128 for ( const css of results ) {
129129 const candidates = await extractValidCandidates ( {
130+ cwd,
130131 base : v4 ?. base ,
131132 css,
132133 sources : v4 ?. sources ?. map ( ( x ) => {
@@ -144,6 +145,7 @@ export class TailwindcssPatcher {
144145 }
145146 else {
146147 const candidates = await extractValidCandidates ( {
148+ cwd,
147149 base : v4 ?. base ,
148150 css : v4 ?. css ,
149151 sources : v4 ?. sources ?. map ( ( x ) => {
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ export interface PatchOptions extends PatchUserConfig {
2929 extendLengthUnits ?: boolean | ILengthUnitsPatchOptions
3030 }
3131 filter ?: ( className : string ) => boolean
32+ cwd ?: string
3233}
3334
3435export 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