Skip to content

Commit 194f4f2

Browse files
Apply feedback
1 parent d977b4f commit 194f4f2

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

@@ -2389,10 +2388,6 @@ test(
23892388
e.toString(),
23902389
)
23912390

2392-
output = stripVTControlCharacters(output)
2393-
.replace(/tailwindcss v(.*)/g, 'tailwindcss') // Remove the version number from the error message
2394-
.replace(/\\/g, '/') // Make Windows paths look like Unix paths
2395-
23962391
expect(output).toMatch(
23972392
/Tailwind CSS v.* found. The migration tool can only be run on v3 projects./,
23982393
)

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)