Skip to content

Commit 7192df2

Browse files
committed
fix: unit test for ci
1 parent 8dce922 commit 7192df2

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

packages/tailwindcss-patch/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
"scripts": {
4141
"dev": "tsup --watch --sourcemap",
4242
"build": "tsup",
43-
"test": "vitest run --coverage.enabled",
43+
"test": "pnpm run patch && vitest run --coverage.enabled",
4444
"test:dev": "vitest",
45-
"patch": "node bin/tw-patch.js install"
45+
"patch": "tsx dev/bin.js install"
4646
},
4747
"publishConfig": {
4848
"access": "public",

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import type { PackageJson } from 'pkg-types'
22
import type { ILengthUnitsPatchOptions, InternalPatchOptions } from '../types'
3+
import { createRequire } from 'node:module'
34
import { defu } from '@tailwindcss-mangle/shared'
45
import path from 'pathe'
56
import { gte } from 'semver'
67
import { monkeyPatchForExposingContextV2, monkeyPatchForExposingContextV3, monkeyPatchForSupportingCustomUnit } from './patches'
78

9+
const require = createRequire(import.meta.url)
810
export function internalPatch(pkgJsonPath: string | undefined, options: InternalPatchOptions) {
911
if (pkgJsonPath) {
10-
// eslint-disable-next-line ts/no-require-imports
1112
const pkgJson = require(pkgJsonPath) as PackageJson
1213
const twDir = path.dirname(pkgJsonPath)
1314
options.version = pkgJson.version

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import path from 'pathe'
1+
import { createRequire } from 'node:module'
22
import { internalPatch } from '@/core'
3+
import path from 'pathe'
34

45
const tailwindcssCasePath = path.resolve(__dirname, 'fixtures')
56
const versionsPkgDir = path.resolve(tailwindcssCasePath, 'versions/package.json')
6-
7+
const require = createRequire(import.meta.url)
78
function getTailwindcssVersion(str: string) {
89
const match = /^tailwindcss([\d.]*)$/.exec(str)
910
if (match === null) {
@@ -18,7 +19,6 @@ function getTailwindcssVersion(str: string) {
1819
}
1920
}
2021

21-
// eslint-disable-next-line ts/no-require-imports
2222
const pkg = require(versionsPkgDir)
2323
const versions = Object.keys(pkg.dependencies)
2424

packages/tailwindcss-patch/test/postcss8-v3.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import type { Config } from 'tailwindcss'
2-
import path from 'pathe'
2+
import { createRequire } from 'node:module'
33
import { TailwindcssPatcher } from '@/core/patcher'
44
import { processTailwindcss } from '@/core/postcss'
5+
import path from 'pathe'
56
import postcss from 'postcss'
67
import { appRoot } from './utils'
78

9+
const require = createRequire(import.meta.url)
810
describe('postcss', () => {
911
it('getCss 0.common', async () => {
1012
const p = path.resolve(appRoot, '0.common')
@@ -45,7 +47,6 @@ describe('postcss', () => {
4547
},
4648
}
4749
const { css } = await postcss([
48-
// eslint-disable-next-line ts/no-require-imports
4950
require('tailwindcss')({
5051
config,
5152
}),

scripts/postcss7-compat/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "postcss7-compat",
3-
"version": "1.0.1-alpha.0",
3+
"version": "0.0.0",
4+
"private": true,
45
"description": "",
56
"author": "",
67
"license": "ISC",

0 commit comments

Comments
 (0)