Skip to content

Commit f942429

Browse files
Apply feedback
1 parent 5f9ffe8 commit f942429

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

integrations/upgrade/index.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { stripVTControlCharacters } from 'node:util'
21
import { expect } from 'vitest'
32
import { candidate, css, html, js, json, test, ts } from '../utils'
43

@@ -2266,10 +2265,6 @@ test(
22662265
e.toString(),
22672266
)
22682267

2269-
output = stripVTControlCharacters(output)
2270-
.replace(/tailwindcss v(.*)/g, 'tailwindcss') // Remove the version number from the error message
2271-
.replace(/\\/g, '/') // Make Windows paths look like Unix paths
2272-
22732268
expect(output).toMatch(
22742269
/Tailwind CSS v.* found. The migration tool can only be run on v3 projects./,
22752270
)

packages/@tailwindcss-upgrade/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async function run() {
6262

6363
// Require an installed `tailwindcss` version < 4
6464
let tailwindVersion = await getPackageVersion('tailwindcss', base)
65-
if (tailwindVersion && Number(tailwindVersion.split('.')[0]) > 3) {
65+
if (tailwindVersion && Number(tailwindVersion.split('.')[0]) !== 3) {
6666
error(
6767
`Tailwind CSS v${tailwindVersion} found. The migration tool can only be run on v3 projects.`,
6868
)

packages/@tailwindcss-upgrade/src/utils/package-version.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import fs from 'node:fs/promises'
2-
import { resolve } from 'node:path'
32

43
/**
54
* Resolves the version string of an npm dependency installed in the based
65
* directory.
76
*/
87
export async function getPackageVersion(pkg: string, base: string): Promise<string | null> {
98
try {
10-
console.log('getPackageVersion', pkg, base)
11-
const packageJson = resolve(base, 'node_modules', pkg, 'package.json')
12-
const { version } = JSON.parse(await fs.readFile(packageJson, 'utf8'))
9+
let packageJson = require.resolve(`${pkg}/package.json`, { paths: [base] })
10+
let { version } = JSON.parse(await fs.readFile(packageJson, 'utf8'))
1311
return version
1412
} catch {
1513
return null

0 commit comments

Comments
 (0)