Skip to content

Commit 96075ec

Browse files
committed
chore: bump version
1 parent 0341352 commit 96075ec

File tree

9 files changed

+37
-344
lines changed

9 files changed

+37
-344
lines changed

.changeset/ripe-news-dream.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tailwindcss-patch": patch
3+
---
4+
5+
fix: CacheManager error

packages/tailwindcss-patch/src/core/cache.ts

+8-11
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,24 @@ export class CacheManager {
5555
await fs.outputJSON(filename, [...data])
5656
return filename
5757
}
58-
catch {
59-
logger.error('write cache file fail!')
58+
catch (error) {
59+
logger.error(error)
6060
}
6161
}
6262

6363
async read() {
6464
const { filename } = this.options
65+
const isExisted = await fs.exists(filename)
6566
try {
66-
if (await fs.exists(filename)) {
67+
if (isExisted) {
6768
const data = await fs.readJSON(filename)
6869
return new Set<string>(data)
6970
}
7071
}
71-
catch {
72-
logger.error(`parse cache content fail! path:${filename}`)
73-
try {
74-
fs.unlinkSync(filename)
75-
}
76-
catch {
77-
logger.error(`delete cache file fail! path:${filename}`)
78-
}
72+
catch (error) {
73+
logger.error(`path:${filename}`)
74+
logger.error(error)
75+
isExisted && await fs.remove(filename)
7976
}
8077
}
8178
}

packages/tailwindcss-patch/src/core/candidates.ts

-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ function importOxide() {
1010
return import('@tailwindcss/oxide')
1111
}
1212

13-
// function importTailwindcss() {
14-
// return import('tailwindcss')
15-
// }
16-
1713
export async function extractRawCandidatesWithPositions(
1814
content: string,
1915
extension: string = 'html',

packages/tailwindcss-patch/test/cache.test.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,17 @@ describe('cache', () => {
7777
dir,
7878
file: 'merge-multiple-context.json',
7979
},
80+
patch: {
81+
output: {
82+
removeUniversalSelector: false,
83+
},
84+
},
8085
})
8186
await twPatcher.setCache(new Set())
8287
await getCss(['text-[100px]'])
8388
let ctxs = twPatcher.getContexts()
8489
expect(ctxs.length).toBe(1)
85-
let set = await twPatcher.getClassSet({
86-
output: {
87-
removeUniversalSelector: false,
88-
},
89-
})
90+
let set = await twPatcher.getClassSet()
9091
expect(set.size).toBeGreaterThan(0)
9192
expect(set.size).toBe(2)
9293
expect(set.has('text-[100px]')).toBe(true)

packages/tailwindcss-patch/test/candidates.ts

-295
This file was deleted.

packages/tailwindcss-patch/test/inspector.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import path from 'pathe'
21
import { inspectPostcssPlugin, inspectProcessTailwindFeaturesReturnContext } from '@/core/patches/exportContext/postcss-v3'
32
import fs from 'fs-extra'
3+
import path from 'pathe'
44

55
const tailwindcssCasePath = path.resolve(__dirname, 'fixtures')
66
const twltsLibPath = path.resolve(tailwindcssCasePath, 'versions/3.3.1/lib')

0 commit comments

Comments
 (0)